• We are looking for a content creator to help market our assets and a future unannounced project. More details are on this page.

Hiding shared variables in behavior tree component (patrolling AI example)

rasponien

New member
Hello

I created a simple patrolling AI with the following layout and I created two shared variables for controlling that logic - waypoints (to store waypoint references, which could be places in the level and changed when placing prefab in the level) and currentWaypointIndex (to store current waypoint index).
1642961410986.png
1642961372368.png

My question: Is it possible to somehow hide temporary/state related variables like currentWaypointIndex in the Behavior tree component, which I don't need to edit when I am placing patrolling enemy prefab in the level. I would only need to change the waypoints array.
1642973588453.png

Or should I approach patrolling AI logic somehow differently?


I also looked up, another way to solve this issue could be by using task references (https://opsive.com/support/documentation/behavior-designer/referencing-tasks/) - create currentWaypointIndex variable in task SetNewPatrolPoint and reference it in MoveTo task. But this creates a problem with the reusability as I now need to always have SetNewPatrolPoint task reference in MoveTo task.

Any advice with this problem is much appreciated.
Thank you in advance.
 

Justin

Administrator
Staff member
There isn't a way to hide variables but for this situation I would use the BehaviorTree.FindTask method to search for a task and then reference that task within the original task. This should give the most flexibility and is similar to the node references behavior but it's done through code so it'll be easier to maintain.
 
Top