0 votes
var bodies = get_colliding_bodies()

for body in bodies:
    if body.is_in_group("Blocks"):
        body.queue_free()

I am making a Breakout,
In the current code, when trying to determine the hit of a block,
In addition to not hitting at all, the following error comes up and it is troubled.
This the Error:

ERROR: RigidBody2D::get_colliding_bodies: Condition ' !contact_monitor ' is true. returned: Array()
   At: scene\2d\physics_body_2d.cpp:785
asked Sep 23, 2017 in Engine by keito940 (48 points)
edited Sep 26, 2017 by eons

Edited redundant lines to make it more legible

1 Answer

0 votes
Best answer

Maybe you are trying to get colliding bodies with contact monitor disabled.

Check the inspector to see if that is the case, also increment the number of collisions to detect (both properties are close to each other in the inspector).

answered Sep 26, 2017 by eons (7,786 points)
selected Oct 3, 2017 by keito940

There was no mistake in the inspector,
In my project, blocks, balls and walls are separated into different scenes.
The first split that is raised assumes that there is a wall in the scene of the ball.
Perhaps there is a cause there?
Also, when you divide the scenes, please tell me what to do with the hit judgment of a different scene. (It's a beginner ...)

Rigid bodies are cpu intensive so most properties are disabled by default, some of these are the contact monitor and the contacts reported (which only works if monitor is enabled).

If contact monitor is disabled, the get_colliding_bodies will not work.

If contact monitor is disabled, the getcollidingbodies will not work.

So what should we use?

With the contact monitor disabled you can' t use something that is supposed to work only with contact monitor enabled.

Your only option is to enable the contact monitor and set the contacts reported > zero.

thx.
...But, How can I check the contract monitor?
Also, what should I do to erase the block?

In the scene editor, select the rigid body then look at the inspector, one of the options is a checkbox for that property.

After that option gets enabled, you will be able to use the method to get colliding bodies, also the "body_enter" signals which can be more useful.

Tnx.
I turned on the contract monitor.
But how do you turn off the block?

With the monitor on and contacts reported over zero, the code should work (for freeing the node).

For just disabling, you can play with collision layers.

How can I check if I report zero?

Next to the contact monitor is a property for the max possibly reported, by default zero.

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.