Legacy GM Gamemaker 8.1 object_get_id workaround

When an object is placed into a room, it seems to get its own id, is there a way to reference the object using that id?

Last edited:


First, read up on the difference between objects and instances, which applies to all versions of GM. You're trying to get at an instance here, not an object.

Except for specific contexts such as functions starting with object_*() or the last argument to instance_create(), almost everything else that can take an object ID to talk about something in a room can also take an instance ID to be specific about one out of many instances. Two examples:
with (105492) instance_destroy();
None of this is difficult, you just have to stop insisting on object IDs where instance IDs are also accepted and needed for the task at hand.


GMC Memer
GMC Elder
Also, the way these IDs work changed in GMS1.x (and again in GMS2). Hardcoding the ID you see in the room editor will cause the project to break if you ever import if (unless you manually change references to the new format). I recommend using Instance Creation Code (right click --> creation code) instead if possible. (Which also changed behavior in Studio, running after the create event instead of before).