Rebirth after death

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaxTuz

after the death of the player how to make him respawn at the spawn point

:bust_in_silhouette: Reply From: exuin

You can set the position of the player to the spawn point’s position through code. You’ll probably also want to reset some other variables too, like health or something.

I use this code at the end of the enemy:

func _on_Area2D_body_entered (body):
if body.is_in_group (“Player”):
body.kill ()

What code should be written to make me revive, otherwise I don’t quite understand

MaxTuz | 2021-01-11 18:29

In your player script have something like this:

var spawn_pos = Vector2(0, 0) # replace with spawn point position

func kill():
    position = spawn_pos

exuin | 2021-01-11 18:55