Godot: The number of Contacts Reported does not match.

Created on 13 Jun 2020  路  3Comments  路  Source: godotengine/godot

Godot version: 3.2.1
OS/device including version: Windows10, gtx1050, GLES3

Issue description:
Download the archive.
CR_Test.zip

Open Project and follow the steps below, referring to the red marks in the image.
c
In the Inspector, every time you increase the value of Contacts Reported to 1, 2, 3...Press F5 to make the player collide with RB2D. The move is WASD.

The output counts the number of collisions with RB2D. (by body_entered for signal)
Since RB2D is a duplicate, the collision should occur at the same time, since they are all the same size and location.

For some reason this value does not match.
Even if I set the limit to 5, it doesn't count 5.
I read that this glitch has been fixed in the past.
Am I checking the wrong way?

archived bug confirmed physics

Most helpful comment

This is due to edge collisions (the sides of the colliding rectangle collision shapes are parallel), which report 2 contacts per shape collision: one at each end of the colliding edges. Parallel face collisions in 3D report 4 contacts per shape collision! The important point is: there is a difference between the collisions between shapes and the contacts generated by those collisions.

In the example project, when the number of contacts is set to 5, an edge collision records two contacts with the first shape, two contacts with the second shape and one contact with the third shape. At this point, the limit of the number of contacts to record is reached. So, the second contact with the third shape is not stored. Neither are the contacts with the subsequent shapes. The signal is designed to only emit one signal per body, even if there are two contacts or the body has multiple shapes. The result is only 3 signals are emitted.

So this is not a bug. There's a difference between contacts and collisions. To ensure that signals from up to 5 collisions are received, in 2D the number of contacts needs to be set to 10, and in 3D the number of contacts needs to be set to 20.

Finally, it's worth noting that although the engine is designed to store the most significant contacts, in the example project, all the shapes are exactly the same and in the same location, so it just stores the first five contacts. There is no way to predict or control the order.

All 3 comments

It seems to only be reporting half (rounded up) of the number of contacts.

This has something to do with the fact that they are edge collisions, which report two contacts each. Rotating the player so it collides with the corner reports the expected number of contacts.

This is due to edge collisions (the sides of the colliding rectangle collision shapes are parallel), which report 2 contacts per shape collision: one at each end of the colliding edges. Parallel face collisions in 3D report 4 contacts per shape collision! The important point is: there is a difference between the collisions between shapes and the contacts generated by those collisions.

In the example project, when the number of contacts is set to 5, an edge collision records two contacts with the first shape, two contacts with the second shape and one contact with the third shape. At this point, the limit of the number of contacts to record is reached. So, the second contact with the third shape is not stored. Neither are the contacts with the subsequent shapes. The signal is designed to only emit one signal per body, even if there are two contacts or the body has multiple shapes. The result is only 3 signals are emitted.

So this is not a bug. There's a difference between contacts and collisions. To ensure that signals from up to 5 collisions are received, in 2D the number of contacts needs to be set to 10, and in 3D the number of contacts needs to be set to 20.

Finally, it's worth noting that although the engine is designed to store the most significant contacts, in the example project, all the shapes are exactly the same and in the same location, so it just stores the first five contacts. There is no way to predict or control the order.

We should probably amend the documentation to note that contacts aren't reported in a deterministic manner (if not done already).

Godot's physics engines in general aren't expected to be deterministic; we should try to make this clearer.

Was this page helpful?
0 / 5 - 0 ratings