Access external object variables?

NodeCanvas Forums Support Access external object variables?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13675
    hellhound
    Participant

    Hi Gavalakis,

    is it possible to access variables and properties of objects which are not part of the owner of the BT itself, but a child in the object hierarchy? I use ScriptableObjects as blueprints for my object configurations to get my architecture as modular as possible. By this reason I got a blueprint for each weapon type, which could be used by the avatar which is the owner of the BT. The blackboard is located at the avatar which should only have a reference to the weapon which is in use, any weapon specific value should be located at the weapon which it belongs to.

    However in a weapon specific sub-tree of the avatar BT I need access to those values (i.e. amount of ammunition, range etc.) to create conditions for the avatar and weapon BT. Is there a way to access those values without adding them directly to the avatar to access them from the avatar blackboard? This will blow up my avatar with values and components which are logically not part of this object. Those values should be part of the weapon (prefab) which could be changed at runtime …

    I could also imagine to use a separated blackboard located at the weapon and referenced by the main BT. Or locate the sub-tree for weapon at the weapon with an separated blackboard for this sub-tree by referencing it from main BT at runtime.

    #13681
    Gavalakis
    Keymaster

    Hello,

    I am really sorry for this late reply.
    Right now at least, Blackboard Variables can only be bound to the field/properties of components that are attached on the owner. However, you could set up a “Bridge” component with properties that in turn return (get and/or set) the properties you need from the child weapon prefab in runtime and bound those properties to blackboard variables. Unoptimized example code:

    As a result, the bound variable to the ‘weaponAmmunition’ property, will in runtime return the ammunition of whichever weapon is currently child of the avatar with any logic you might want it to. You would of course still need to attach this “bridge” component on the owner gameobject though, but is this something you want to avoid completely?

    Let me know.
    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #13686
    hellhound
    Participant

    Hello,

    thanks for your reply. This is an option, but breaks the decoupling concepts I try to set up based on the ScriptableObject delegate pattern presented by Ryan Hipple on Unite 2017 (https://www.schellgames.com/blog/insights/game-architecture-with-scriptable-objects).

    Actually I think about implementing special condition tasks referencing those objects to perform the checks instead of using base conditions, referencing the blackboard (i.e. a special CheckAmmunition, CheckRange condition task). This task could access the weapon referenced by the avatar. I know this couples the task but only the task …

    Best regards,
    Christian

    #13694
    Gavalakis
    Keymaster

    Hello again,

    Hmm. What would the ideal solution (NC ability/feature) be for your use case?
    Would that be to be able to bind Blackboard variables to “child” gameobject/component properties and fields, or something entirely different?
    I would be interested to know 🙂

    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.