Randomized Motion

This tutorial will demonstrate how to create an animation graph for motion randomization. We'll use the ForceFollow attribute of links.

  • Create a new view and new states.

The 'FooRandomGate' state is a gate state that forwards the current state to one of the linked states, when selected. Other states are just sample animation states for randomization.

Set up inputs for testing.

Use the Stance input for this tutorial. Set up the states as follows:

FooRandomGate

Use the Default template because you don't need any animation for this state. Set the 'Stance' criterion to test_random.

FooSample0

It's a force-followed state. Therefore, it doesn't need the Allow selection check. Use the IdleOneShot template.

FooSample1

This is the same as above, except with a different animation string. For this, you can use the clone utility.

FooSample2

This is the same as above, except with a different animation string.

Link the states as follows:

Edit the 'ForceFollow' attributes by right-clicking the dot in the middle of the link curve; a popup menu is displayed, as follows:

Set Force follow chance to 1 for all 3 links. Then, all the 3 states will have the same chance of being forwarded.

After editing, you can see a small digit beside the dot of the link. This shows the value of it, as follows:

Test it using ag_ commands.

Click the AI/Physics button to enable the AI.

  • ag_debug target_name
  • ag_stance test_random

Note that the 3 animations are randomly played, repeatedly.