Room Start Event Execution Order for Persistent Objects in GameMaker: Studio

It’s a well known fact that GameMaker: Studio 1.4 follows this order of events:

  1. Create Event of each instance
  2. Instance Creation Code of each instance
  3. Game Start Event (this will only be run in the very first room of the game)
  4. Room Creation Code
  5. Room Start Event of all instances

You can set the order in which specific instances are created within the room editor itself. But what about the Room Start event of persistent instances? Such instances are carried over from room to room. What if we have a room with another, newly created instance, that also executes a Room Start event?

room_01                 room_02
obj_persistent -------->obj_persistent
                        obj_new

I made a few tests and it seems that GameMaker, for this specific case, uses Depth. That is: the smaller/lower the depth value of the instance, the sooner it will execute its Room Start event.

I’m talking about instances and not objects because if we change the instance’s depth via code, GameMaker will use that value, not the one defined inside the object editor.

Now jump into your code and have dozens of objects with different conflicting Room Start events (I’m kidding, please don’t)

Liked it? Take a second to support Nikles on Patreon!

What are your thoughts on this?