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

  • stuck.jpg
    stuck.jpg
    32.7 KB · Views: 12
  • flock.jpg
    flock.jpg
    46.7 KB · Views: 12
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).
 
If you enable logging on the behavior tree component does it give an indication as to why the task stopped?
 
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).
 
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.
 
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.
 
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