GMS 2 Persistent Objects De/Activation in Room Start and Room End

Chris Smith

Hey guys, so I've been doing a game jam, and naturally some stupid stuff got me all kinds of stuck for almost a whole day now. I've been finding little things because of this, but not making any progress. But I've gotten my main issue down to an issue regarding activating objects.

So here's the rundown.
When the game starts, the first thing I do is create 62 instances of obj_npc, with various things within them being randomized. In the first room they are all left active, as the title screen just displays all of your NPCs and it's kinda neat. I like it.

The way I want to control which rooms the NPCs show up in, is by activating all obj_npc in the Room End, and deactivating them all in the Room Start event (and reactivating all the NPCs that are supposed to be active in that room) - since persistent objects that are deactivated at Room End will be discarded, and I don't want that... so I activate them all for the last frame.
However. it seems like activating them on Room End is still discarding them. But if they're active before Room End, they're just fine.

1. Why does activating on Room End not work?
2. How would you suggest activating them shortly before room end?

Many thanks, friends.

Update: Here's a video I made displaying the issue and relevant code.
Last edited:

Chris Smith

Welp I figured it out, of course, almost immediately after i post in here. I figure I'll leave it for posterity's sake.

It seems that instance activation just doesn't happen fast enough to do in Room End. So I just set an alarm and let that do the job.

Here's a video showing the fix, for any future searchers.


Friendly Tyrant
Forum Staff
Yep, you've found the issue correctly. Instance activation/deactivation takes a step to complete, so if you are doing it in the room end event, the instances will be flagged as activated, but won't get the required step to actually activate before the room changes.