Topic was automatically imported from the old Question2Answer platform.
Asked By
dang_
Hi, I need help with getting my game to restart when the character is killed. Also for it to restart at the original location and for the enemy character to still be dead if they were before. Any code and advice would be helpful. The game is a 2d maze rpg.
If the character is Kinematic it’s quite trivial in the character’s script to do something like:
var starting_position
func _ready():
starting_position= position
func respawn():
position = starting_position
When the scene first loads the starting position of the character is saved in a variable, when the player dies that position is retrieved and set as the current position.
Consider resetting any relevant variables. along the way. Having a dedicated function to handle initialization and recalling it might be helpful depending on complexity