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

GameMaker [SOLVED] Persistent object disappearing

J

Joky

Guest
So I have an object that is persistent and when switching rooms and then back it disappears.

Any solutions?
 
A few questions up front. Do you have any code in your object that would cause it to destroy itself? Are your rooms different sizes? Is it disappearing when you go from the room its created in to a second room, or only when you go back to the first room from a second room? One quick check I'd do is putting in a show_debug_message in a room start or destroy event to make sure its actually disappearing and something else isn't happening.
 
J

Joky

Guest
no destruction no different room sizes when I go from first room to second and then back it disappears
 
You're going to need to post some code: anything in your persistent object that pertains to changing rooms and any code in other objects that handles room changes or effects your persistent object.
 
J

Joky

Guest
Step:
Code:
if (kids = 5)
{
    object_set_visible(obj_kid,false);
    obj_cash.cash = obj_cash.cash + 15
    kids = 6
    alarm[2] = room_speed * 2
}
Alarm:
Code:
kid = 0
room_goto(rm_earnings)
Button That Can Be Clicked In 2ND Room To Go Back:

Code:
if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x, mouse_y, obj_green) && (obj_greenbutton.dead = 0)
{
      room_goto(rm_office)   
      obj_cash.x = 3092
      obj_cash.y = 512
      obj_kid.kids = 0
      obj_kid.kid = 0
      obj_greenbutton.good = 0
      obj_greenbutton.bad = 0
      audio_play_sound(snd_knockknock,1,false)
      audio_resume_sound(snd_music)
      
      obj_kid.alarm[0] = room_speed * 2
 
Alright, so you set obj_kid to be invisible if the kids variable equals 5, but nowhere in your code (at least the code you've provided) is it set to visible again. You've reset the kids variable to 0, but that doesn't automatically change visibility back after its set to false just because kids no longer equals 5.
 
J

Joky

Guest
Forget to add this XD



Code:
if (kids = 5)
{
    object_set_visible(obj_kid,false);
    obj_cash.cash = obj_cash.cash + 15
    kids = 6
    alarm[2] = room_speed * 2
}

if (kids < 5 && !kid = 0 && obj_door.door = "open")
{
obj_kid.visible = true
}

if (kids > 5 || kid = 0 || obj_door.door = "closed")
{
obj_kid.visible = false
}
 
J

Joky

Guest
I fixed it! I just instead of making obj_kid persistent so the kid and kids variables stay I just put them all in an object that was already persistent.
 
Top