Platfomer Respawning issue

So I’m making a platformer game, and in the game, there are two variables(“Respawn_X” and “Respawn_Y”) that determine where the player will respawn if it dies. the problem is that sometimes the game randomly decides to change the spawn location of the player for no reason, and either softlocks the game by respawning the player inside the ground or sends the player to the start of the level. In this image, the player always starts the scene in front of ‘Closed_Door’ (so it is always colliding with the door when you start any level).

Hello, sonicpoweryay

When your Player dies, are you deleting the instance and creating another one, or are you just changing the position? Can you show these events?

Is player half the same size image as player? If player half dies does it respawn as player?

The collision box of the Player Half is half the size of the collision box of the Player

Yes, the player will always respawn as the ‘Player’ character.

Hello. This game lets the player change their character in a level by standing a special tile. The game creates a ‘Player Half’ instance in the exact position of the ‘Player’, and then deletes the ‘Player’.

The issue about the player respawning in places that they’re not supposed to spawn in happens regardless of which character is being used, but it mostly happens when the ‘Player’ dies. But that’s mostly because I don’t die a lot when using ‘Player Half’, so I’m not sure.

If the player is deleted then when player half collides with the checkpoint then it has no object to assign a value to. Even if the player wasn’t deleted it still wouldn’t work because of the way or works in Gdevelop.

Maybe, you need 2 separate events.
If player collides with checkpoint set player variables
If half player collides with checkpoint then set half player variable

Or you could put them both into a group and use
if playerGroup collides with checkpoint then set PlayerGroup variables

OR in Gdevelop doesn’t just check for true or false but it’s also picking the objects. So, if an object isn’t in collision with the checkpoint, then it doesn’t get picked which means you can’t change the variable.

I’m wondering if the default values for the player variables are being used or an older value. Variables also don’t survive deletion. So, anytime you delete an object it loses all previous values.

1 Like

wait so you can’t change an object’s variable if there are no instances of it in the scene?

1 Like

Not if they don’t exist. The objects you create are just templates or blueprints . You don’t use them. You use the objects or instances that are added either through the editor or through actions.

I tried using scene variables and the problem got even worse. now it always spawns the player at 0,0 even though I am pretty sure I set the variables to 1600,800.

Please post a screenshot of the events. That’s the only way people can help you.