Playing walking motions straight ahead with random start

A very common issue for beginners is having a few characters playing a walking motion straight in front of them.

This tutorial only focus on playing a motion "as-is" straight ahead of a character and with some randomness in the animation. If you are looking to send your characters toward a given target (involving path-finding & AI), see the Populate City Tutorial

The desired result


Characters all moving straight forward and playing the same animation, but with different start frames

What not to do

The intuitive way to do this would be to use a single Motion behavior  and configure its start percent to have entities starting at random frames. but doing it this way will bring characters all moving in different directions instead of moving in the same one.


Result of applying a Motion behavior with random start percent between 0 and 1

The reason it's not working is that each frame in the motion has a different root orientation, and thus bring a different main orientation of the displacement.

What to do

To force our characters to follow a given orientation, we need to use the other animation Behavior: Locomotion or SyncMotion Behavior.

 

1/ Create and EntityType, and Terrain and place your characters (see Quickstart if needed)

2/ Open the Behavior Editor, double-click on your EntityType and drag-and-drop a SyncMotion behavior 

 

3/ Double-click on the SyncMotion behavior and choose a motion to be played (in our example, the Locomotion/CMAN_RunNormal_Leftfoot.gmo motion from the Character Pack).

Note: Because the elbows are retargeted strangely with this motion on the usual CrowdMan character, we check the IK plane roll from Animation attribute in the Advanced Attributes at the bottom of the behavior (SyncMotion Behaviors have 2 advanced attributes panels, one specific at the top, and one inherited from Motion Behavior at the bottom). See Assets Conversion FAQ for more details.

 

4/ We want to synchronize only the orientation of the animation, not the position of our characters. We want them to run from where they were placed and keep ground adaptation. So just uncheck "Synchronize 2d position" and "Synchronize height" on the Advanced Attributes at the top of the Behavior.

You should also increase the Start Percent Max to 1, in order to randomize the point in the animation where each character will start.

 

5/ Check if the synchronized motion is played with the right orientation related to your character starting orientation. Either play the simulation, or use the SyncMotion Behavior display attributes to display a wireframe view of your motion (your need to choose and EntityType).

In our case, the Motion is playing -X front, and we want our character to go X front.

 

6/ To easily change the orientation of your characters, we need to map a locator to it as a reference, and then rotate the SyncMotion Behavior as needed.

For example, you could map the Population Tool, or create a usual Maya Locator. Select the locator in the outliner, the holding the SHIFT button, select the SyncMotion Behavior and click map in the Configuration panel

Then select the SyncMotion Behavior in your viewport (the green locator showing how the motion will be played), and rotate it as needed. 

Note: you could just rotate the mapped locator as well, but in this simple case, it is more user friendly to orient the SyncMotion.

And you are done!