Construct 3 icon

Construct 3

Documentation

Instance script interface

Ashley's avatar
Medal
Construct Team Founder
Published 28 May, 2019
304 words
~1-2 mins

The IInstance script interface represents a single instance of an object type (represented by IObjectClass). Instances that appear in the layout have a IWorldInstance interface instead, but it derives from IInstance, so these methods and properties are available for any type of instance.

Many objects return a more specific class deriving from IInstance or IWorldInstance to add APIs specific to the plugin. See the Plugin interfaces reference for more information.

Instance APIs

runtime

A reference back to the IRuntime interface. (This is particularly useful when subclassing instances, since in a custom class's methods you can always refer to the runtime with this.runtime.)

objectType

The IObjectClass interface for this instance's object type.

instVars

If the object has any instance variables, they can be accessed by named properties under this property. For example if an object has an instance variable named health, it can be set and retrieved using instance.instVars.health. Note if the object has no instance variables, the instance won't have an instVars property at all.

uid

The unique ID of this instance, as a number.

destroy()

Destroy the instance, removing it and releasing any memory associated with it.