Attribute expression (AtomsUnreal)

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

Only the Windows platform support attribute expressions!

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 component.

 

image-20241018-144839.png

 

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

 

image-20241018-144906.png

 

Now press the image-20241018-144927.png button to open the expression editor.

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

 

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; }

 

Packaging

When you use expressions and you want to package your project you need to add the AtomsJIT folder to folder copy list inside the project settings.

 

Copyright © 2017, Toolchefs LTD.