State machines (AtomsUnreal)

For creating a state machine, right-click on the content browser then select Atoms Crowd / Atoms State Machine. Double click on the state machine asset to edit it.

For creating animation states right click on the viewport and select "add state".

The State Details

In the State Details panel, you can set up states, blend spaces and transitions.

In case you're setting up a state or a blend space, you have to give it an id (Node Id) which will later be used by several Atoms Behaviour Modules such as the State machine (a unique id is given set as default by the editor). Each state in the same state machine must have a different id.

State

You can assign more than one Animation Sequence (Clip) to each state or transition.
For each Animation Sequence there are three different merge types:

  • Exclusive : only the exclusive clip will be played. This mode has the highest priority. If you have an exclusive clip all the other clips will be ignored. If you have more than one exclusive clip only the first one will be used.

  • Merge : all merge clips will be merged together. This has higher priority over the random mode. Having only a merge clip is like setting its mode to exclusive.

  • Random : one of the random clips in the list will be played. At the end of each clip, another random clip is used. 

There are also seven different motion types: Straight, TurnLeft, TurnRight, TurnUp, TurnDown, BankLeft, BankRight.
Only clips with the same motion mode will be merged together, randomized or will exclude each other.

The Sync value makes sense for turning clips only (motion type not being straight). With this value, users specify whether or not the turning clip is in sync with the main straight clip.

The angle and blend angle fields are enabled only when the motion type is not straight and the sync value is set to "Yes".
At each frame, your agent direction changes and the angle described by the agent direction at the current frame and the direction at the previous frame will be used by the blending system.
For instance, when setting a TurnLeft clip with angle value to 1 and blend to 2, our agent will start blending the Straight clip with the TurnLeft clip when the mentioned angle will be between from 1 to 3 degrees (3 is simply the angle value plus the blend value). When the angle will be more than 3 the TurnLeft clip will be played.
The angle and blend values are in degrees.

When use clip direction clip is set to "Yes" the user is instructing Atoms to use the clip direction instead of the agent direction metadata. The angle field has meaning in this case too: the clip will start playing when the angle variation between the previous frame and this frame reaches this value.
The max turn angle field limits the angle variation (degrees) at each frame.

The tag field can be used in two different scenarios:

  • For random clips, users can control the random probability of each clip with a metadata. Specify the metadata name inside the tag field, then add a metadata with that name on your simulation agents. The metadata value represents the weight used by the random function, it can be a boolean, int or double.

  • For merge clips (straight), users can control the weight of each clip with a metadata. Specify the metadata name inside the tag field, then add a metadata with that name on your simulation agents. The metadata value represents the weight of the clip, it can be a boolean, int or double.

  • For additive clips, users can control the weight of that clip on an agent. Specify the metadata name inside the tag field, then add a metadata with that name on your simulation agents. The metadata value represents the weight of the additive clip, it can be a boolean, int or double.




More settings affecting the entire state are available:

  • The max turn angle field limits the angle variation (degrees) at each frame.

  • Random loop option; when an agent enters the given state and the state has all clips in random mode: a) Off, a random clip will be picked and it will be used in a loop; b) On, a random clip will be picked at random every time playing clip ends.

Whenever a one-shot clip (non-loopable clip) is used inside a state, the transition will be triggered as soon as the animation of that clip ends.

 

Blend space

The blend space node is used to reference a blend space asset. This asset is used to blend multiple clips at the same time.

The agent “targetLinearVelocity” double metadata is used to blend the clip on the X-axis, while the “targetAngularVelocity” double metadata is used to blend the clips on the Y-axis of the blend space.

The “MaxLInear/AngularAcceleration” property are used as max acceleration values in units/second.

Transitions

When connecting two states you can select the transition and assign a transition clip within the State Details.
A two arrow icon will appear on your transition in the editor as soon as you assign a clip to it.

The transition settings are similar to the state's, the only difference is that you can specify a blend in and out frame value for the transition itself.

If you don't specify a transition clip between two states, Atoms will do a straight blend between two states.

If two states do not have a transition you won't be able to pass from one to the other.



Tutorial

To create a state machine asset:

  • Select at least an anim sequence asset.

  • From the Atoms Crowd menu execute the "Create a state machine" action.

  • The action generates a new state machine asset.

  • Save the asset.

  • Open the agent type asset you created before and assign the new state machine to the state machine property.

If you want to test the agent type asset:

  • Create a new AtomsAgentGroup actor.

  • Add a Grid layout behaviour component

  • Select the grid layout component and on the agentType property set the agent type asset you created before.

  • Add a state machine behaviour component.

  • You should now see an agent that is playing the first clip you selected when you created the state machine asset.

  • Change the state property on the state machine component to select the other anim sequences.

 

 

Copyright © 2017, Toolchefs LTD.