This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello I am working on a pong game in godot. Everything is going well so far but I recieve this error in my debugger: E 0:01:55.112 body_set_shape_as_one_way_collision: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead. <C++ Error> Condition "body->get_space() && flushing_queries" is true. <C++ Source> servers/physics_2d/physics_2d_server_sw.cpp:739 @ body_set_shape_as_one_way_collision() @ _on_Area2D_body_entered()

here is my code for instancing a duplicate ball:

extends Node2D

var collect = false
var ballscene = null

func _ready():

func _on_Area2D_body_entered(body):
        collect = true
        var ball =  load("res://Scenes/BallDuplicate.tscn")
        ballscene = ball.instance()

yes I instance the ball in the power up and not my spawn manager.

Godot version 3.2.3
in Engine by (30 points)

1 Answer

+1 vote

Thats just a thing with physics server, it is often busy with querries and will have troubles doing some operations at the moment of collisions. You should get used to calling deferred, just as this error suggests. So instead of addchild(ballscene) You will need to calldeferred("add_child",ballscene).

by (8,188 points)

Thanks! This fixed the exact same problem I was having. Do you recommend to always add children in deferred mode? Seems like the sensible thing to do.

I suggest using deferred calls only when console error demands it :)
If physicsserver has no problem, than it is better to resolve your actions in exact frames they were called, otherwise You may eventually encounter small bugs due to timing of code resolve. In short, non-deferred calls are more predictable, making debugging a bit easier.

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.