How do I…
How do I make a respawn/checkpoint system after the player dies across multiple scenes?
What is the expected result
I want to make it so that, when a player dies (their health goes to 0), they’ll change rooms to respawn at the last checkpoint they touched.
When the player touches a checkpoint and I exit out of the game, they’ll respawn in the room with the checkpoint and at the position I specified.
What is the actual result
When the player dies, nothing happens. They don’t change rooms or change position.
When the player touches a checkpoint and I exit out of the game, they’ll respawn in the room with the checkpoint, but not at the specific position.
First screenshot is the loading screen, second is the first and starter scene, third is the second room with the checkpoint, and last is the external event with my failed coding attempts.
I’ve tried out different tutorials, but because they work on using only one scene, I can’t get it to work with multiple rooms. I’ve also double-checked and made sure the external events are linked to the rooms.
I think I have all the pieces to the puzzle, but I’m not putting them in right. I welcome any feedback.
I’ve been following in your other thread, pretty sure you almost have the kinks ironed out.
Here on your load image, I was wondering if it was a mistake.
Because it looks like you’re reading a string from storage, converting it into a global variable and then immediately overwriting it before using it for anything.
This one from office:
The global var Saving is going to equal 1, because that’s what it was set to in load screen, so you can probably leave that out. Might want to swap the save spot doesn’t exist and save spot does exist in storage. In this situation I don’t believe it matters since it will just correctly write 1 and then load it, but good to stay in GDevelop best practices when ordering events. Might want to swap bool dead = false before switching scene in case it switches scene literally before it finishes that box, although I suppose it’s at default anyway so probably ok.
No good changing position of BigD before switching scene. It will be a new scene and won’t know you changed the position of BigDiablo in the last scene right before you sent him to this scene. So you can change that to a global variable and in each scene check if that global var is w/e and if so then change the position. Or even more simply, just read savespot in each scene. So in office read and store savespot in scene var and if = 2, send to kitchen, if = 3 send to diningroom. Then in kitchen, check if it exists in storage at beg of scene and if so, read it, store it in scene var and if = 2, set BigD position to w/e and if not, nothing. Same on diningroom.
I’m not seeing any events of saving. Like when he dies.
For the questions you asked:
For the actions in the Load image, I was following one of the tutorials to set that up. I think it was this one: Saving & Loading (Storage) - Advanced Tutorial - GDevelop - YouTube
I wonder if I don’t need the Change Global Variable for Saving
For the game scenes, Saving is a Scene Variable, not a Global Variable. I’ve tried to do this with only global variables in the past and got no where. This tutorial, which used scene variables, was the only one to help me make progress: How to save a game state : GDevelop 5 - YouTube
I don’t actually know what to do in regards to the player dying besides programming in a boolean global variable. I’ve looked up tutorials, but I didn’t get anywhere with those.
I’m wondering if the variables are conflicting with each other? If the room variables are telling the player to spawn in Position 1, but the Checkpoint variable is telling it to go to Position 2.
I tried clearing the room variables when the player is dead, but that didn’t do anything. It’s like the game isn’t registering that the player is dead. this is weird because that wasn’t a problem before.
That could be that they’re conflicting. Is clearing a variable done ingame? I’m wondering if you should delete them out of storage when the player dies, or just overwrite them. I’ve got an idea I want to try but unfortunately if won’t be till this evening.
I made a new game file where I can experiment with the global variables without other programming getting in the way.
EDIT: There’s a storm tonight, so the internet might be bad.
I had a pretty horrible time with it haha. I sent you a message with the results. I think. I don’t see it now. Let me know if not I’ll send the link again.