Set Instance Variable Action Set Instance Variable

With this action you can set one of the built-in variables. All instances of all objects have a number of variables already created within them to hold essential information like the current x/y position, the speed, the direction, visibility and many other things. The instance variables that you can use are:

Once you select the built-in variable to use, you then set the value for that variable. The value you use will depend on the variable selected (see the list above for defaults and ranges) and you can flag the value to be relative to the current value for the variable. You can also add additional variables to set in the same action by clicking the plus icon Expand Argument Icon beside the action, and selecting another instance variable and giving it a value.

 

Action Syntax:

Set Instance Variable Action

Arguments:

ArgumentDescription
VariableThe built in variable to set
ValueThe value to set the variable to

 

Example:

Set Instance Variable ExampleThe above action block code gets the values for the previous x/y position and then compares them to the current x/y position. If they are not the same, then the sprite index for the instance is changed and it's image index is set to 0.