Skip to main content

The "instance_link" Function

Syntax#

instance_link(parent, child, pos, rot, scale);
ArgumentTypeDescription
parentinstanceThe parent instance to link properties from
childinstance/object/arrayThe child instance or collection of instances to link properties to
posbooleanEnables or disables linking child instance position relative to the parent
rotbooleanEnables or disables linking child instance rotation relative to the parent
scalebooleanEnables or disables linking child instance scale relative to the parent

Description#

Links an object, instance, or array of them to the parent instance so that all child objects match the parent's position, rotation, and/or scale. Links are relative, meaning child objects can still have their own independent position, rotation, and scale as well.

Unlike the child, the parent must be a specific instance. Use self or id to indicate the running instance. If an object is input as the parent, the first randomly detected active instance of the object will be used.

Must be run in the Step Event for changes to position, rotation, and scale to apply continuously.

important

This function depends on comparing values across time. It is highly recommended that you do not run instance_link inside a conditional statement, as this can lead to incorrect results.

Example#

instance_link(obj_grid, obj_cell, true, true, true);