Use creation expression values in a runtime expression
 
 
 

A runtime expression can’t read a variable you’ve defined in a creation expression unless you define the variable as global. However, you can create a custom attribute, assign it a value in a creation expression, then read or write its value in a runtime expression.

For example, suppose you assign a particle object’s position to a variable named $oldposition in a creation expression:

vector $oldposition = particleShape1.position;

The runtime expression for the same particle shape node can’t read the contents of the $oldposition variable. To solve this problem, you can create an attribute for the object, assign it a value in the creation expression, then use the attribute value in a runtime expression.

For example, suppose you create an attribute named oldpos, and assign it the following position in a creation expression:

particleShape1.oldpos = particleShape1.position;

You can read the value of particleShape1.oldpos in a runtime expression.

You don’t need to create an attribute to hold the object’s initial position. The initial position already exists in its initial state attribute named position0. This attribute doesn’t appear in the Expression Editor’s Attributes List.