RIgidBody2D Collision Error.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By keito940
:warning: Old Version Published before Godot 3 was released.
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

Edited redundant lines to make it more legible

eons | 2017-09-26 03:23

:bust_in_silhouette: Reply From: eons

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).

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 …)

keito940 | 2017-09-26 08:19

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.

eons | 2017-09-26 11:58

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

So what should we use?

keito940 | 2017-09-27 05:51

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.

eons | 2017-09-29 02:32

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

keito940 | 2017-09-30 04:18

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.

eons | 2017-09-30 15:02

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

keito940 | 2017-10-01 05:28

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.

eons | 2017-10-01 15:02

How can I check if I report zero?

keito940 | 2017-10-03 07:54

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

eons | 2017-10-04 00:24