Accessing the GameObject the Tree is running on

tikitofu

New member
Hi, I created a new Action which tries to return closest resource to the GameObject on an ExternalBehaviorTree. My function in the Action requires the GameObject that the Behavior Tree is running on.
However, I'm having trouble being able to define that. Would that be considered a 'SharedGameObject'? I'm not able to find the definition of shared variable in the docs. Are shared variables ones you define inside of a behavior tree?

Also, I'm trying to follow the RTS example, but it doesn't seem to use ExternalBehaviors, rather copying/pasting of trees. Is there an example using ExternalBehaviors (which I assume would be the better approach to having multiple objects running the same tree)?

Hopefully my question made sense, thanks!
 
It looks like I needed to set .Value as my object:

Code:
SharedGameObjectSource.Value = this.gameObject;
 
Using the value property is the way to set the SharedVariable value. However, if you are just using the GameObject within your task you can use the gameObject field and there's no need to set a SharedVariable. This page has more info on the variable system: https://opsive.com/support/documentation/behavior-designer/variables/

The RTS sample project does use external trees so is a good example to look at. The unit behavior tree will use an external tree in attacking the different objects.
 
I will look at just using the gameObject field - and yes, it looks like you are using an external behavior for the Attack. Thank you!
 
Top