Legacy GM Gamemaker 8.1 object_get_id workaround

Discussion in 'Legacy GameMaker Community Tech Support' started by TheHappyFaceKing, Nov 22, 2019.

  1. TheHappyFaceKing

    TheHappyFaceKing Member

    Jan 6, 2018
    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: Nov 22, 2019
  2. FrostyCat

    FrostyCat Member

    Jun 26, 2016
    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.
  3. Yal

    Yal GMC Memer GMC Elder

    Jun 20, 2016
    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).

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice