Skip to main content

8. Flocking with Predator

Flocking combined with avoiding a predator (red) in 2D and 3D.

This sample shows combination of flocking and predator avoidance. There are two subscenes one for 2D and one for 3D. Each subscene contains a flock of entities similar to previous example. The entities here use FleeJobWrapper to escape a predator. The predator uses SeekingJobWrapper to chase the entities. When the predator is not seeking anything, the WanderingJobWrapper makes it wander around randomly. This example also shows the usefulness of neighbor query groups. The entities can use one query to find their flockmates and another query with a different tag to find the predator.


The subscenes contain one predator in red color and SpawnerAuthoring which spawns in a flock of entities. There is several HomeAuthoring which the entities use to stay in a general area. The same homes are used by both the predator and the prey entities.

Description of the image