I need help with making my person respawn after falling, how do i do this?

godot 4

i don’t know how to make my person die and respawn after dying, HELP WANTED

Can you provide more information?

I see you used the 2d tag, what kind of 2d game are you making?
Do you have an example of what you’re trying to achieve? (Eg the falling / game over from 2D Super Mario games)

1 Like

A platformer and yes it is like super mario

The way I did it was in my _process function, I had an if statement like this:

func _process:
     if global_position.y > 500
          global_position = Vector2.ZERO
#if you would like, you can add an extra line or two to respawn somewhere else.
          global_position.x += 150
          global_position.y -= 150
#this will respawn the player 150 units up and right
1 Like

I will try that

An even better way would be:

func _process:
     if global_position.y > 500
          global_position = Vector2(150, -150)
# This will spawn the player at the same spot (150, -150), but only in one line of code.

1 Like