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)

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.