GameMaker: Studio

GameMaker: Studio

View Stats:
robert_belko Apr 20, 2019 @ 6:55am
Need help with getting the instance ID of objects in a room manually for further calls
Greetings lads, I'd need some help with finding the predetermined IDs for objects in a room.
The reason I need to do this, is I want to make a cover finding system and I want to manually cherry-pick covers from the room editor to let the enemy use. But the ID you can check in the Room Editor, starting with "inst_XXXXXX" is not the instance ID that is used in-game.

So my question is, is there any way for me to check the actual in-game instance ID of a object I've put down in the Room Editor? Thanks for helping, even if you choose not to.
Originally posted by Zappy:
You can try to right-click(?) a single one of the cover instances in the room editor, choose "Creation Code", and type something like ...
show_message("Instance ID: "+string(id));
... in it, run the game, see the message, note down the instance's ID, and then remove that creation code from it in the room editor.

Though, if the instance ID is different between multiple runs of the game (which may very well be the case, as a previously-code-spawned persistent object could have the same instance ID, which would definitely break stuff), that may not work.

In that case
, you can try to do the cherry-picking using something like instance_nearest(x,y,obj)[docs.yoyogames.com] to check for a cover instance near specific coordinates instead of supplying a direct instance ID.
< >
Showing 1-8 of 8 comments
maras Apr 20, 2019 @ 7:00am 
You can get IDs using variable 'id'
The author of this thread has indicated that this post answers the original topic.
Zappy Apr 20, 2019 @ 7:17am 
You can try to right-click(?) a single one of the cover instances in the room editor, choose "Creation Code", and type something like ...
show_message("Instance ID: "+string(id));
... in it, run the game, see the message, note down the instance's ID, and then remove that creation code from it in the room editor.

Though, if the instance ID is different between multiple runs of the game (which may very well be the case, as a previously-code-spawned persistent object could have the same instance ID, which would definitely break stuff), that may not work.

In that case
, you can try to do the cherry-picking using something like instance_nearest(x,y,obj)[docs.yoyogames.com] to check for a cover instance near specific coordinates instead of supplying a direct instance ID.
Last edited by Zappy; Apr 20, 2019 @ 7:17am
robert_belko Apr 20, 2019 @ 7:22am 
so use coordinates of the object to use as reads for the ID of the instance and then supply that to the grid list, gotcha lads, thanks for the support, appreciate it
The Winter Bud Apr 20, 2019 @ 8:40am 
One way is to stuff all the id's into a list
///create event of controller object coverlist=ds_list_create(); with(obj_cover){ ds_list_add(other.coverlist,id); } // you now have all the id's of all the cover object in a list
robert_belko Apr 20, 2019 @ 8:41am 
Originally posted by The Winter Bud:
One way is to stuff all the id's into a list
///create event of controller object coverlist=ds_list_create(); with(obj_cover){ ds_list_add(other.coverlist,id); } // you now have all the id's of all the cover object in a list

I'd rather do the instance_nearest thing to make my job easier, but thanks for the suggestion
Zappy Apr 20, 2019 @ 8:42am 
Originally posted by The Winter Bud:
One way is to stuff all the id's into a list -Some code-
From what I understand (based on the words "cherry-pick"), TheOnlyRobert wants to make a specific enemy want to go to a specific cover object instance, so having the cover instance IDs in an unorganized list might not be of much help.
Last edited by Zappy; Apr 20, 2019 @ 8:42am
robert_belko Apr 20, 2019 @ 8:44am 
Originally posted by Zappy:
Originally posted by The Winter Bud:
One way is to stuff all the id's into a list -Some code-
From what I understand (based on the words "cherry-pick"), TheOnlyRobert wants to make a specific enemy want to go to a specific cover object instance, so having the cover instance IDs in an unorganized list might not be of much help.

exactly, couldn't have said better
The Winter Bud Apr 20, 2019 @ 11:10am 
it was just a thought :)
< >
Showing 1-8 of 8 comments
Per page: 1530 50