Using the CharacterController for avoidance

The CharacterController Behavior enables you to get character avoidance based on a physical shape approximating your characters. The biggest advantage is that it is computed post-animation, meaning that it enables you to get character avoidance even when just playing a Motion behavior (which is not possible e.g. with the Navigation Behavior).

In this tutorial we will generate a characters playing various motions from walk to run and avoiding each others thanks to the CharacterController Behavior.

1. Create an EntityType and load a character (e.g the Fortress Soldier from the Golaem Assets)

2. Create a Population Tool and place a bunch of characters

3. Open the Behavior Editor and add a Motion Behavior. Double-click on it to load several motions inside (E.g walk, walk fast, run from the Golaem Assets Motions/Battle directory). The motions will be distributed among the different characters.

4. Run the simulation. You should notice several characters going through each others. Indeed without Navigation Behavior, there is no Artificial Intelligence running and characters are only playing animation

5. Make sure that all your motions are going straight. E.g for this tutorial, we had to edit the run motion Motion Clip in order to remove a rotation on the root (hence sending all running characters to the left...). This would not be a problem with a Locomotion Behavior because this latter adapt the orientation of your character to the path it is following, but not the Motion Behavior.

6. Drag and drop a CharacterController Behavior on top of the Motion Behavior in order to create a Parallel Operator containing both behaviors

7. The default radius of the CharacterController Behavior approximation Capsule being 1m, your characters capsules could collide with each others before even starting, thus leading to characters stuck in each others. Replace the Radius attribute by 0.3 which is the usual radius for a human character.

8. Rewind the simulation and play again. You should notice that running characters collide in walking ones and finally slide on their side in order to avoid them and continue their path

9. For debug purposes, it is possible to display the CharacterController capsules, by enabling the Physics Shapes display on the Physics Locator. 

Note: remember that physics shapes display is always 1 frame late compared to the simulation which explains some discrepancies between the characters and the shapes when they are running fast.