• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

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:

FrostyCat

Redemption Seeker
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:
Code:
(105492).sprite_index
Code:
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.
 

Yal

šŸ§ *penguin noises*
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).
 
Top