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
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
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
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()
*get_parent().get_node("Position2D")*
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.
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
You can store the playerâs coordinates in a global node.
Project â Project Settings â Autoload
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.