Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

You can add an expression to an attribute. Atoms uses C++ as an expression language.

On a expression, you have three variable as input that you can use to access various data:

  • agent: is an AgentWrapper object. You can use it to access agent metadata, or pose transforms.

  • agentGroup: is an AgentGroupWrapper object. You can use it to access other agents or do space queries.

  • defaultValue: it contains the default value of the attribute.

and an output variable called “output”. You need modify the output variable passing the attribute value that you want.

Example

Create an agent group and add a grid layout and a state machine module.

image-20241014-121607.png

Press on the randomize button net to the state attribute until you activate the expression mode.

image-20241014-121709.png

Now press the “open editor” button to open the expression editor.

Add the expression like in the picture below and press save.

image-20241014-121903.png

if you press play, the agent switches its state to 1 when the frame is higher then 20.

For example if you want that only the agent with groupId 1 switches to state 1 you can write an expression like this:

if (agent.groupId == 1 && agentGroup.time() > 20)
{
	output = 1;
}
else
{
	output = defaultValue;
}

Or when an agent has a specific metadata value

if (agent.getIntMetadata("myMeta") == 1 && agentGroup.time() > 20)
{
	output = 1;
}
else
{
	output = defaultValue;
}
  • No labels