Construct 3 icon

Construct 3


Instance Variables

Ashley's avatar
Construct Team Founder
Published 16 Aug, 2017
229 words
~1-2 mins

Instance Variables are added to object types but store numbers, text or booleans (on/off flags) individually for each instance. This makes them ideal for things like health counters, since each instance tracks its own value. Instance variables are added to object types with the Object Instance Variables dialog, and the initial values for each instance can be set from the Properties Bar.

Click here to open an example of instance variables.

Instance variables can also be used to help control instances independently of each other. For example, a Boolean instance variable could be used to determine if an enemy is hunting down the player (true) or running away (false). If instances all have different values, the condition Is boolean instance variable set can be used to apply actions to enemies hunting down the player. Inverting the condition (picking instances with the value being false) can then be used to apply actions to enemies running away. The end result is a number of instances of the same object type acting independently: some chasing and others running away. This is a simple example - much more complex methods can be made using multiple instance variables. In other words, an instance's state can be controlled using instance variables.

Instance variables can also be added to Families Paid plans only. All the object types in the family then inherit the instance variable.

All Contributors

  • Ashley's avatar
    Last edited 28 Aug, 2017
    ~1,959 chars in 2 edits
  • Tom's avatar
    Last edited 16 Aug, 2017
    ~8 chars in 3 edits