Tactical, Surround task acts like an ordinary attack

Justin

Administrator
Staff member
Is there a specific task for this? How are they going to surround without one specific leader?
There's not a specific task but you can use shared variables to set the leader. In the demo scene take a look at the change leader example. The code is within BehaviorSelection.EnableBehavior with the ChangeLeader block.

What do you mean by: "I will have the task more gracefully handle this situation by returning failure."
In the next update I will have the task fail instead of throwing the error.
 

tpetsrule

New member
I had the same problem. I'm using a script to keep track of my group's current leader and send a new leader to all behavior trees in the group via a SharedGameObject when the old leader dies or is destroyed, and I would get the same null reference error if a Tactical task was running when the leader changed. Interestingly, the Formations tasks didn't have this problem at all and switched leaders smoothly, while the Tactical tasks would spam the null reference.

What fixed it for me was going into the OnUpdate() method in TacticalGroup.cs and changing both instances of "return TaskStatus.Running" to "return runStatus". This way the task fails correctly when EndFormation() is called. It's coded like this in FormationGroup.cs already.
 
Top