How to respawn my player exactly where he died

Godot Version
3.6 beta

I am trying to implement a system that when the player died he will respawn near a ground where he died not the starting position

create a Timer and always move the respawn position to the player’s position… set the Timer as you need, every second or two. as it suits you.

Check is_on_floor() to make sure you don’t create a position in the air. and best to remember the 3 positions to the rear. this is in case you accidentally generate a position and it’s in a damage trigger and a deadend occurs.

For demonstration. I created a deadpoint as Position2D and refresh its position only when the player is on floor after falling

the golden diamond is the last safe position where the player can respawn after his death

:godot: TURRiCANOS


This is exactly what I was looking for but I am still a beginner so can you explain more briefly about the code or the setup not too detailed but a little bit that I can understand
Thank you : ⁠)

And what type of game do you do? Sidescroller or TopDown?

I am making a jump king type game with other unique mechanics and I need this system to make the easy mode for the game

Could you post a screenshot of what your game looks like? Just to give you an idea of what exactly is going on

Okk wait

This is just the prototype

Please explain

you can either use the starting position or create a new one in the level that you will update. The best is Position2D and call it what you need

You will update Position2D with the player’s position, say every second. You can then adjust the time according to the needs of the gameplay

The best thing for you to do is to use Timer. Add it to the player

Create signal for Timer

and setup your Timer

and via signal update every second Position2D in player script

func _on_Timer_timeout():
	get_parent().get_node("Position2D").position = self.get_global_position()

of course, I don’t know how ist your tree sctructure, then adjust your path correctly for Position2D in level

and when the player dies, then call only for the respawn Position2D which you updated last.

You just have to make sure that you don’t update the Position2D position during the player’s death so that you don’t overwrite the last one you’ll need on respawn

of course, this is very simple explanation… you will also have to check if the player is in the damage zone or in the fall etc. during the respawn.

I get it but when player die it reload the whole scene so how to prevent position 2d from resetting it’s possible thanks you described everything pretty well and if you have any demo project or tutorial which I can follow than please suggest me and thank you from everything

in that case, I guess it’s your concept and logic of how the level and death of the player works, I don’t see it…

Obviously, after the death of the player you call the whole scene again and the start position of the level is reset. it might be necessary to slightly modify the logic and make the level and the player separate.

The death of the player shouldn’t call a scene refresh but only the last position. I don’t know if the player has a given number of lives available. If so, the scene reload should only happen when all lives are used up.

This is my scene tree

If you have any example project please share

I am almost lost I tried everything. there is nothing about this on YouTube, Google, reddit, quora please help

Your project TURRiCANOS looks very nice

1 Like

You can store the player’s coordinates in a global node.
Project → Project Settings → Autoload

1 Like

if you are unable to figure this out, it might be best to work on something else for a while. i have a bulletin board and notebooks of things i need to do.

if something is giving me that much trouble, i work on something else for a while.

try searching other threads for global variables.

Yes, this is the fastest solution. Just create a script , make a Vector2D var and add the script to the autoload. Then you can update that position and reference it when you reset your scene.