instance_copy

Creates a copy of the calling instance.

Syntax:

instance_copy(perf);


Argument Description
perf Whether to perform the new instance's Create event (true) or not (false).


Returns: Real


Description

With this function you can "clone" an instance as this will create a new version of the instance running the code at its same position. The "perf" argument is used to instruct this new instance to perform the create event or not. This function returns the id of the new instance which can then be stored in a variable or used to access that instance.

NOTE: If you choose not to perform the create event, you may encounter errors if the instance depends on any variables initialised in this event.


Example:

var inst;
inst = instance_number(object_index);
if inst < 10
   {
   instance_copy(true);
   }


Back: Instance Functions
Next: instance_create
© Copyright YoYo Games Ltd. 2018 All Rights Reserved