Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This module creates all the nodes needed by the state machine (clip reader, merge, state machine) inside the DG network of each agent; then, the "state" metadata is used to play the right animation clip based on the data from the state machine.

Setup

  • Create an agent group.

  • Add a grid layout module and set the size attribute to (3,3,1).

  • Add a state machine module.

  • Set a valid id number in the state attribute of the state machine module

  • Press play

  • You can override the state of some agents with other state ids if your state machine has any.

  • Press play.

Set start frame

The start frame property controls the start frame of the clip. If you put -1, every agent uses a random value. If you want to set a specific frame on some agents. Open the start frame override dialog. Select the agents from the dialog or using the layout tool. Set a valid frame inside the value field and press the set value button. You can use blueprint to set the start frame using the SetFrame() and SetFrameOverride blueprint function of the clip reader component. Please remember to call it in the init simulation event.

Change state

You can change the agent state using the state property. You can use the state override or the blueprint function SetState() and SetStateOverride() to change an agent state. This can be called during the simulation. You can also control the agent’s state using the “state“ int metadata on each agent. If you want to change the metadata during the simulation instead to call the SetState/StateOverride(), please remember to check the “Set State at Creation Only” property. Otherwise, at every tick, the state machine component will overwrite the metadata value.

Change velocity

Change the frame rate property to change the agent velocity. You can the velocity using the SetFrameRate() and SetFrameRateOverride() function of the state machine component. The agent velocity can also be changed using the “frameRate“ double metadata of each agent. If you are going to change this metadata during the simulation, please remember to check the “Set Frame Rate at Creation Only“ properties. Otherwise, at every tick, the state machine component will overwrite the metadata value.

Change state using an area trigger

With this component, you can change a metadata value when the agents enter inside a mesh area

  • Create an agent group

  • Add a grid layout module and set the size to (3,3,1)

  • Add state machine module. Set the "state" attribute of the stateMachine module to 1

  • Create a plane, scale it and place it in front of the agents

  • Add an area trigger module to your agent group

  • Select the plane in the mesh attribute of the area trigger module

  • Leave the metadata attribute in the area trigger module to state

  • Set the intValue attribute in the area trigger module to 2, in this way the agents will change the state to 2

  • Leave the keepValue on so the agents will keep the new state value

  • Press play.

Image Added