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

While it is not strictly required, it is recommended to run this script with obj_gmlp in existence. Without obj_gmlp, if rotation or scale linking is enabled, only one instance of instance_link can be run per object instance.

Example#

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