0 votes

So when my player falls off the map, I want the level to reload. I have used an area2d with a collisionshape2d to create an area that will call a function when the player collides with this area. However, when the game is run with this code included, the player will animate through a few frames then the game completely freezes before I can even move the player.

func _on_Area2D_body_entered(body):
get_tree().change_scene('res://level1.tscn')

If I delete this code, or set monitoring to off, and re-run the game it will not freeze.

Below is a screenshot of my level design.

Level design

Any help would be greatly appreciated :) - Is this a bug or am I doing something stupid?

Godot version 3.4
in Engine by (14 points)

1 Answer

0 votes

restart the scene

gettree(). reloadcurrent_scene()

and this = ('res://level1.tscn') # error ("res://level1.tscn")

by (650 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.