I’m following two courses where the instructor uses get_tree().reload_current_scene() to reset a level when a player (characterbody2d) enters or exits an Area2d using the body_entered or body_exited signals. The code works but I I get a massive list of errors in the debugger (red ones, not mere warnings). The instructors do not get the errors in the videos I’m watching. One of the errors mentions something about using call_deferred() instead but I have little idea what this is. Can anyone please clarify what is going on? I’m a relative newcomer to Godot.
I’ve just noticed that every time I go into/out of an Area2d, triggering the signal I get two errors:
E 0:00:04:0908 level_1.gd:15 @ _on_maze_body_exited(): This function can’t be used during the in/out signal.
<C++ Error> Condition “locked” is true.
<C++ Source> scene/2d/area_2d.cpp:328 @ _clear_monitoring()
level_1.gd:15 @ _on_maze_body_exited()
E 0:00:04:0908 level_1.gd:15 @ _on_maze_body_exited(): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead.
<C++ Source> scene/2d/collision_object_2d.cpp:98 @ _notification()
level_1.gd:15 @ _on_maze_body_exited()