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 Next »

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.

Finally, you can change the attribute value by assigning a value to the “output” variable.

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 only the agent with groupId 1 to switch to state 1, you can write an expression like this:

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

You can do the same by checking if an agent has a specific metadata value:

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