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

how to restart a room?[solved]

L

Lerchprinz

Guest
i know, a very stupid question... but how can i actually use the room_restart() function?

this:
if(life <1){
room_restart();
}

is just freezing my game. if i change room_restart to game_restart it restarts the whole game, but i just want to repeat the current room when dying.
if i use my TRANS.MODE.GOTO function, the game reloads the room, but my player object stays at the point where he died...

any ideas?
 
I assume your player object is persistent from what you are saying. Room restart won't effect persistent objects (unless you have code in their Room Start event, which is the only thing that will be run on room_restart()). The game freezes because you check to see if life is below 1 in your player object. It is, so the room restarts. The next step, you check to see if life is below 1 in your player object, since it is persistent and it will continue exactly as it was before when the room restarts, life is indeed below 1, so it restarts the room. Repeat ad infinitum. You could reset the life variable back to whatever the max is in the Room Create event of the player object.

The player object is staying in the same place for the same reason. It's x and y values don't get reset on the room restarting because it is persistent. You could also use the Room Start event to position your position your player according to where they should be when the room starts.

However, the usual advice is to not use object persistence precisely because of problems like this.
 
L

Lerchprinz

Guest
I assume your player object is persistent from what you are saying. Room restart won't effect persistent objects (unless you have code in their Room Start event, which is the only thing that will be run on room_restart()). The game freezes because you check to see if life is below 1 in your player object. It is, so the room restarts. The next step, you check to see if life is below 1 in your player object, since it is persistent and it will continue exactly as it was before when the room restarts, life is indeed below 1, so it restarts the room. Repeat ad infinitum. You could reset the life variable back to whatever the max is in the Room Create event of the player object.

The player object is staying in the same place for the same reason. It's x and y values don't get reset on the room restarting because it is persistent. You could also use the Room Start event to position your position your player according to where they should be when the room starts.

However, the usual advice is to not use object persistence precisely because of problems like this.
my player object is not persistent and the dying animation is at a different object that the player transforms to.
I dont want to have lifes in my game anyways, because it is going to have a one touch death system like in meat boy. Even if i just make a room_restart(); at the colision, it is not restarting....
 
V

VagrantWhaleGames

Guest
my player object is not persistent and the dying animation is at a different object that the player transforms to.
I dont want to have lifes in my game anyways, because it is going to have a one touch death system like in meat boy. Even if i just make a room_restart(); at the colision, it is not restarting....
is the object holding the life variable persistent? Like Crazy Star said, you might have to reset it back to something so the player isn't dying instantly and the game is infinitely restarting. Otherwise, i'd start by trying to find which object is causing the problem...Which if it happens on player death, already narrows it down.
 
L

Lerchprinz

Guest
is the object holding the life variable persistent? Like Crazy Star said, you might have to reset it back to something so the player isn't dying instantly and the game is infinitely restarting. Otherwise, i'd start by trying to find which object is causing the problem...Which if it happens on player death, already narrows it down.
nothing is persistent. And even if i dont use the player_death object at all and try to make a room restart with my player object the room does not restart.... or at least my player object is not moving from his point of death...

EDIT: i tried it with resetting the life variable and now the transition animation is happening, and my character respawnes. but he respawnes at the same poin he died.

EDIT2: i added a y-=200 variable to a roomstart event. when i get hit by an enemy, my character actually gets up by 200. so this means the room restarts, it is just not affecting my player object.... but why?
 
Last edited by a moderator:
L

Lerchprinz

Guest
Wait, what version are you using? If it's studio 2, I have to look at that again. LOL
ok, i am back again... this whole room restarting thing is causing some troubles... could you look again?^^
was finally able to fix it by myself... thanks everyone!
 
Last edited by a moderator:

TheouAegis

Member
So which part are we having the issue with? The player not restarting in the right spot or the room crashing the game?
 
Top