Changing scenes part of Martian Mike!

Getting Error messages in output.:-

E 0:00:03:0676 level.gd:53 @ _on_exit_body_entered(): 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.gd:53 @ _on_exit_body_entered()*

E 0:00:03:0676 level.gd:53 @ _on_exit_body_entered(): 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.gd:53 @ _on_exit_body_entered()*

Checked Godot 4.2 documentation and it mentions using call_defered() with Get_tree().reload_scene().

So used this below:-

get_tree().change_scene_to_packed.bind(next_level).call_deferred()

Get no errors now, is this a bug in the new Godot 4.2.2 or is it the proper way to do this?

2 Likes

This has cropped up multiple times in the last few days. This was always the proper way to do it (there are several ways of writing the syntax), but the error has become more visible lately. It does appear as though 4.2.2 has changed the way this is handled, though I did still encounter this in 4.2.1 when I started extending my projects from this course.

Good job finding the solution! :+1:

1 Like

Privacy & Terms