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, need help, not understand why there's error. Thank you.

extends Area2D

onready var rock = preload("res://enemies_sprites/throw_goblin/rock_on_ground.tscn")

var player_position
var start_position
var arc_position
var t = 0

func _physics_process(delta):
    t += delta * 1


func _quadratic_bezier(p0: Vector2, p1: Vector2, p2: Vector2, D: float):
    var q0 = p0.linear_interpolate(p1, D)
    var q1 = p1.linear_interpolate(p2, D)

    var r = q0.linear_interpolate(q1, D)

    position = r
    return r

func _on_rock_area_entered(area):
    if area.is_in_group("Player"):

func _on_rock_body_entered(_body):

func gone():
    var R = rock.instance()

E 0:00:07.122 bodysetshapedisabled: Can't change this state while flushing queries. Use calldeferred() or setdeferred() to change monitoring state instead.
<C++ Error> Condition "body->get
space() && flushingqueries" is true.
<C++ Source> servers/physics
2d/physics2dserversw.cpp:652 @ bodysetshapedisabled() @ gone() @ onrockbodyentered()

Godot version v3.4.4
in Engine by (22 points)

You are not showing us where the error is pointing.
In any case, in my experiments setting the monitoring property of an Area2D via code will not work directly.

$Area2D.monitoring = false     # this won't work

You have to use set_deferred():

$Area2D.set_deferred("monitoring", false)         

Similar changes to Collision properties such as disabled also need to use set_deferred.
See this post

1 Answer

0 votes
Best answer

In the gone() function, the node calling queue_free() is being freed. The thing is, some other node still needs something from that node, but it's going to be removed from the scene tree, i.e. freed. There could be code identified with body_set_shape_disabled, but I don't know what that code is. The code for the gone() function may have to be tweaked like this:

func gone():
    var R = rock.instance()
    get_parent().call_deferred("add_child", R)

But I don't really know because I can't find the code body_set_shape_disabled in the code you've provided.

by (3,164 points)
selected by

It work, thank you.
Btw, what 'call_deferred()' do?

it calls the method when the node isn't "busy", i.e. during idle times when calculations and other things aren't being thrown around. When the parts of the node aren't being removed from RAM via queue_free(), it'll execute the code add_child() on the parent node.

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.