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 beside the action, and selecting another instance variable and giving it a value.

Action Syntax:

Set Instance Variable Syntax


Argument Description
Variable The built in variable to set
Value The value to set the variable to


Set Instance Variable Example

The above action block code gets the values for the previous x/y position and then comapres 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.