How to make sure that after hitting a spike the player spawns next to it?

Godot Version

v4.2.2.stable.official [15073afe3]

Question

How to make sure that after hitting a spike the player spawns next to it? For example, like in the game Hollow Knight
I know a couple of options, for example, using a timer to update a variable that stores the player’s position every second, but I’m not sure that this is the best option. I also know what can be done near each edge of the earth at the spikes there are checkpoints, but I don’t know how to do it, and it seems to me that it’s not practical because The map in my game is large.How to make sure that after hitting a spike the player spawns next to it? For example, like in the game Hollow Knight.
I know of a couple of options, like using a timer to update a variable that stores the player’s position every second, but I’m not sure if that’s the best option. I also know that there are checkpoints on the spikes near each edge of the earth, but I don’t know how to do it, and it seems to me that it’s impractical, because… The map in my game is large. Please tell me what would be better and how to implement it!

I would try out an Area2D around each spike or start of spikes, if entering this area and on the floor, store the location. If the player jumps, store the location. Then you can respawn to that location.

I would not say that this is convenient, my map is large and consists of many scenes, so doing this on each one is very problematic…
I would start from the fact that I have a special physical layer assigned for spikes in my TailMap

Try your timer method again, only saving location if they are on the floor.

Of course, you can use a timer, but the problem is that it can work on the edge of the platform and then the player will spawn in an awkward position, in the end I did this through Area2D and with every jump, thank you for your help!

I’ve dealt with this in some of my work by storing the player’s position as a global variable when they die or change scene.

When I load a scene I can check the last position against the starting position and apply some logic if they don’t match.