Surround Task Changing Leader Error "Object reference not set to an instance of an object" and Warning "Look rotation viewing vector is zero"

MarkusKer

Member
Hello, I am trying to change the leader of the surround task runtime. I set up 2 behavior trees on the Agents (one for the Leader task and another one for the following Agents). I am setting the leader variable for the following agents via a script after enabling the leader behavior tree. I even tried waiting on the start of the following behavior tree so everything is assigned and ready. However, the issue persists.

Is there some function to dissolve/clean up a formation or am I missing something else?

Regards,
Markus
 
What is line 87 of TacticalAgent for you? For me it's a math operation that will never cause an exception. If it's transform that's causing the null reference then your agent hasn't been initialized. The agent will not be initialized if AddAgentToGroup hasn't been called. I would start by placing a breakpoint there and seeing if that method is called.
 
I have set breakpoints and added debug.log to check if both the leader and the following agent get added to the group. I can see that both are added right after one another. after the following agent is added I get the "Look rotation viewing vector is zero" Log and the agent stops moving. The leader keeps working.
 
What is causing the look rotation log? What angles are causing the rotation to be 0?
 
I could trace it back to the "CenterAttackPosition" function of the "tacticalgroup". With breakpoints and logs, I can tell that there are sometimes no target transforms resulting in the position vector being zero. this does not happen every time.

I even tried setting the target with a game object list.
 
Last edited:
Instead of going back and forth I think that it'll be easier if you can tell me how to reproduce the issue within the demo scene so I can take a closer look at the cause.
 
The issue got resolved to set a target group instead of the tag. My guess is, that searching for tags takes longer than the task to start.
 
Top