Reply To: Multiple AI for one Model.

NodeCanvas Forums General Discussion Multiple AI for one Model. Reply To: Multiple AI for one Model.

#8925
Gavalakis
Keymaster

Hello,

So from what I understand is that you have (for this example) 2 game objects “MasterA” and “MasterB”, and a prefab “Child”.
– MasterA and MasterB have a BehaviourTreeOwner component
– At runtime to instantiate Child
– Child has critical components that you need to access from both MasterA and MasterB

So, for starters 🙂 the agent of the task (eg Animator component) doesnt nesesarily have to be on the Owner. This can be overriden with the toggle control on the right of “Use Self”. If “Child” was not a prefab you could directly reference it.

Now, since “Child” IS a prefab, the way this have to work is that you use Variables.
– So in MasterA and MasterB blackboards you can create a variable lets call it “AnimatorTarget”.
– In the Task, override the agent (toggle control) and select our variable “AnimatorTarget”.
– All that is left is setting the “AnimatorTarget” variable once you instantiated “Child”. For example:

Alternatively , you can instead use the rebust variables Property data binding. So you can have a component on MasterA and MasterB which have a public property for the instantiated runtime “Child”.
In the Variables editor, clicking the small button on the right of the variable (not the x of course), lets you Bind it to a public property in one of the components on the same gameobject as the blackboard is.

Let me know if that is what you are looking for.

Thanks

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