Formation Pack - Swarm Error

Savaghost

New member
Hey there,

Unity version: 2021.1.16f1

I'm trying to get Swarm task to work but am having a hard time. I'm now just trying to copy the demo scene setup, but I get this error:

NullReferenceException: Object reference not set to an instance of an object
BehaviorDesigner.Runtime.Formations.Tasks.FormationGroup.StartListeningForOrders (BehaviorDesigner.Runtime.Behavior agent) (at Assets/Behavior Designer Formations/Scripts/Tasks/FormationGroup.cs:159)

I just have 3 gameobjects with the following AstarPathfinding scripts:

d6aee39ba69c61e06f085d13f1142088.png


7e1398c2a5fcb661ff41052ed7f8c110 (1).png

Thanks!
 
What is line 159 for you? In my project that line points to:

Code:
var targetPosition = TargetPosition(i, 0);

Which will never throw a null reference exception.
 
Does FormationGroup.AddAgentToGroup to group get called for you first? This is the method that initializes the agents array.

If the agent in your screenshot is the leader then the Leader field should be blank and not reference itself.
 
Thanks, the error is cleared when I leave the leader field blank on the leader agent but they still don't move at all. The same agents move towards their target immediately if I give them a pursue task instead for example.
 
They are likely trying to get into a starting position. What is the MoveStatus of the agents when they are waiting? You can see this by setting a breakpoint within FormationGroup.OnUpdate.
 
That indicates that they are in formation and ready to move. Is the Speed value 35 on the FormationAgent? Also, has a destination been set?
 
Not sure what FormationAgent is but it is 35 on both the AIPath and on the Swarm task. Destination is set on the Swarm task's target transform but I don't know if I'm supposed to set it somewhere else too.
 
If the destination is set and the speed value is positive then the agent should be moving. This could be an A* configuration issue. Just to confirm, the demo scene works, correct? Are you using the same A* component values as the demo scene? You could also use the navmesh version of the tasks to ensure the behavior tree is setup correctly since the navmesh is a little easier to configure.
 
Top