Why is my flock stopping?

thretch

Member
Very basic setup: 1 plane with a navmesh surface, some agents, and a flocking behavior. Within seconds they are all stuck (stopped). Tried a new project, default settings for everything, same thing happens. Tried it with and without a repeater.

settings.jpg
 

Attachments

thretch

Member
Another odd thing that happens is when they first start moving, half go in one direction, the other half go in the opposite. They seem to become two flocks (until they stop).
 

Justin

Administrator
Staff member
If you enable logging on the behavior tree component does it give an indication as to why the task stopped?
 

thretch

Member
Are you referring to "Log Task Changes"? If so this is all I get:

1572038045514.png

No new info when they stop (the agents don't all stop at once, but within a few seconds of each other).
 

Justin

Administrator
Staff member
It looks like the task is still running and the agents instead just stop. My guess is that they likely don't have a valid position to move towards so that's why they stop. Instead of setting the position directly try doing a NavMeshAgent.SamplePosition to see if the position is valid. If the position is not valid then a new location can be tested that is nearby.
 

thretch

Member
I've got it working, mostly. It was just a matter of getting the navmesh baking and agent settings right.

However, It's still splitting the flock up into two groups at the start, and they never come back together into a single flock.
 

Justin

Administrator
Staff member
I think that this is related to the flocking algorithm used. The Movement Pack uses flock from this page. I haven't tried it but this page also looks like they have a solution that you could try. This does mean though that you would have to create a new flocking task for it.
 
Top