0 votes

I'm getting a series of 4 errors every time my code runs this script:

var drop = load("res://data/scenes/items/passives/pa_" + equipment + ".tscn").instance()
    drop.position = self.position + Vector2(50.0, 0.0).rotated(randf() * TAU)
    get_parent().get_node("Pa_items").add_child(drop)

Yes, it is spawning a new node everytime it runs.
But I get micro-freezes in my game and also I get these errors:

enter image description here

How do I fix it?

I have no idea why this is happening.

This is what is written in each error (in order):

First:

E 0:00:05.337 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:730 @ bodysetshapedisabled()
Character.gd:149 @ droppassiveitem()
Character.gd:128 @ updateequipment()
Character.gd:446 @ _on
Collisioninteracitonsarea_entered()

Second:

E 0:00:05.341 bodysetshapeasonewaycollision: Can't change this state while flushing queries. Use calldeferred() or setdeferred() to change monitoring state instead.
<C++ Error> Condition "body->getspace() && flushingqueries" is true.
<C++ Source> servers/physics2d/physics2dserversw.cpp:739 @ bodysetshapeasonewaycollision()
Character.gd:149 @ droppassiveitem()
Character.gd:128 @ updateequipment()
Character.gd:446 @ _on
Collisioninteracitonsarea_entered()

Third:

E 0:00:05.349 bodysetshapeasonewaycollision: Can't change this state while flushing queries. Use calldeferred() or setdeferred() to change monitoring state instead.
<C++ Error> Condition "body->getspace() && flushingqueries" is true.
<C++ Source> servers/physics2d/physics2dserversw.cpp:739 @ bodysetshapeasonewaycollision()
Character.gd:149 @ droppassiveitem()
Character.gd:128 @ updateequipment()
Character.gd:446 @ _on
Collisioninteracitonsarea_entered()

Fourth

E 0:00:05.354 areasetshapedisabled: Can't change this state while flushing queries. Use calldeferred() or setdeferred() to change monitoring state instead.
<C++ Error> Condition "area->get
space() && flushingqueries" is true.
<C++ Source> servers/physics
2d/physics2dserversw.cpp:409 @ areasetshapedisabled()
Character.gd:149 @ droppassiveitem()
Character.gd:128 @ updateequipment()
Character.gd:446 @ _on
Collisioninteracitonsarea_entered()

Godot version 3.2.3.stable.official
in Engine by (77 points)

1 Answer

–1 vote

This errors straight forward tells You what to do ;)
Call_deferred() for function add child in last line.

by (1,582 points)
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 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 webmaster@godotengine.org with your username.