godot: Game conversion fails from 3.0.6 to 3.1: Can't change state whilst flushing queries

Possibly related to https://github.com/godotengine/godot/issues/24694

Godot version: 3.1 Beta 2 & 3

OS/device including version: Windows 10 i5 NVidia 1050GTX

Issue description: Converting a project that works in 3.0.6 starts crashing

E 0:00:12:0238   Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead
  <C Source>     servers/physics_2d/physics_2d_server_sw.cpp:630 @ body_set_mode()
  <Stack Trace>  :0 @ Godot.Node Godot.NativeCalls.godot_icall_1_504(IntPtr , IntPtr , Int32 )()
                 PackedScene.cs:94 @ Godot.Node Godot.PackedScene.Instance(Godot.PackedScene+GenEditState )()
                 Main.cs:154 @ void Main.SpawnRock(Int32 , System.Nullable`1[Godot.Vector2] , System.Nullable`1[Godot.Vector2] )()
                 Main.cs:171 @ void Main._on_Rock_Boom(Int32 , Single , Godot.Vector2 , Godot.Vector2 , Boolean )()
                 :0 @ System.Object Godot.NativeCalls.godot_icall_2_516(IntPtr , IntPtr , System.String , System.Object[] )()
                 Object.cs:326 @ System.Object Godot.Object.EmitSignal(System.String , System.Object[] )()
                 Rock.cs:87 @ void Rock.Explode(Boolean )()
                 Bullet.cs:35 @ void Bullet._on_Area2D_body_entered(Godot.Object )()

Steps to reproduce: Open project below, start the game and shoot an asteroid.

Minimal reproduction project: https://github.com/nathanjwtx/space-rocks-3-1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (12 by maintainers)

Most upvoted comments

On a signal callback, when you call a method that affect CollisionObjects properties do it with call_deferred, I do not know what is the C# syntax for it, on GDScript is call_deferred("function_name")

I think this was a warning before, at least on GDScript, maybe is an error now?

Fixed by b84b015.