Plat-former project. Endless falling.

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

So I am making a plat-former game for a School project and I’ve been searching for a while now and can’t seem to find what I think I need. Obviously because it’s a plat-former, there are some holes in the level that the character can fall down. Currently if they do its just and endless fall and I have to restart the scene if I want to try again. I would like to be able to bring the character back to the start of the level without having to restart the scene over and over again. Is there some function or variable that i can use to track the position of the character and if it gets to a certain point change that position?

:bust_in_silhouette: Reply From: kidscancode

When you fall, your y coordinate is increasing. If it goes above a certain value, stick your player back at the start coordinates.

if position.y > 2500: # change as needed
    position = start_position

Alternatively, you can reload

if position.y > 2500:
    get_tree().reload_current_scene()