• 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!

[solved]Persistent Object disappearing when room restarts

elmagnum

Member
I have two objects: o_player and o_holder.
o_holder is persistent and is created when the game starts. o_player is not persistent and only is created when the game room is entered. This one needs variables form o_holder to work.
I put an option to restart the level in the pause menu [room_restart();]. However, when the room is restarted, an error appears saying that the holder object wasn't found by the player object:

Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object o_player:

Unable to find any instance for object index '26' name 'o_holder'
 at gml_Object_o_player_Create_0 (line 2) - level = o_holder.level;
############################################################################################
gml_Object_o_player_Create_0 (line 2)
I believe persistent objects are supposed to persist even if the room is restarted, right? Any ideas on how the holder object is disappearing?

Thank you.
 

Nidoking

Member
Might want to run it in the debugger and see whether there's an instance of o_holder when this event runs or not. A breakpoint in o_holder's Destroy event will tell you if it's being destroyed somehow.
 

elmagnum

Member
Thanks for the tip! Using the debugger I saw the instance wasn't active because I deactivated it in the pause menu. To solve it, I simply added an instance_activate_object(o_holder) in the pause code.
 
Top