object_set_depth(index, depth);
Argument | Description |
---|---|
index | The index of the object to change. |
vis | The new depth of the object. |
Returns: N/A
With this function you can set the depth of a specific object.
This means that all instances of this object that are created
after the depth has been changed will be created at this new
depth, while instances that are already in the room may not be
affected.
Please note that this is not an instance function! You can set the
depth of individual instances using the depth
variable and so have ten instances all with different depths even
though the object in question has the depth set to another value in
the IDE, and even if you change the depth of the object to
something else using this function, all instances that currently in
the room will remain as they were, and only instances created after
calling the function will start with the new depth.
if !instance_exists(obj_Bonus) object_set_depth(obj_Bonus, 10000);
The above code checks to see if an instance of "obj_Bonus" exists and if it does not then the object depth is changed.