Skip to main content

6. Flocking

Flocking with 3D movement.

This sample explains usage of neighbor behaviors through classical use case - flocking. Flocking here is the combination of three behaviors - Alignment, Cohesion, and Separation. All these behaviors are included in the default behaviors.

The first folder - 1. Behaviors contains a scene for each behavior where the behavior is visualized and a scene where the combination of the behaviors is visualized. Then there is a sample scene with flocking for each movement system. For example folder 2. 2D.

Description of the image

1. Behaviors

tip

All movement systems and behaviors can be toggled with an IsActive flag. In the following scenes, the IsActive is set to false on the Movement2DAuthoring to make it easier to understand.

This scene visualizes the result of the CohesionJobWrapper. This behavior makes the entity group up with it's neighbors. The yellow arrow visualizes VelocityResult. The direction is DesiredDirection, the length is proportional to DirectionDesire. The radius where the behavior detects neighbors is shown with the yellow circle.


2. 2D

2D Movement

In this scene you can toggle multiple different subscenes which have different setups of CohesionAuthoring, AlignmentAuthoring, SeparationAuthoring. If an entity goes over a border set on BoxLimiterAuthoring, it is teleported to the oposite side.


3. 3D

3D Movement

In this scene there are three different subscenes containing flocks of different sizes. The larger flock has a more optimized, but simpler neighbor query. This scene also shows usefullness of MultiHomingAuthoring which makes the entities stay within given areas. In the subscenes, the larger the flocks, the larger the homing radii on the HomingComponents. Second new behavior is AlignUpJobWrapper, it prevents the entities from flying up or down at too steep angle.


4. 2.5D

2.5D Movement

This scene shows a flock set up on terrain, bordered by walls. The walls are a third option so far to constraint the entities within an area. The previous two options were BoxLimiterAuthoring and MultiHomingAuthoring.