0 votes

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.

in Engine by (39 points)

1 Answer

0 votes

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

by (41 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.