get_contact_count() returns 1 when there are several collisions

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GreyMiller

In my project (in 2D) i have a wheel that rolls inside a cave and need to detect all points of collision with its surface. The cave has a collision polygon, and the wheel can touch two edges simualtaneously, for example, when it gets in a corner. In this case i expect the state.get_contact_count()to return 2, but it only returns 1. In general the function works and returns 0 when wheel is not contacting. What can possibly be wrong here?
What I’m trying to do is to detect contact points and apply force to the wheel to keep it stick to the surface. Should I use some other functions?

If your wheel is a RigidBody2D, what is the value of the contacts_reported property, in the inspector?

Zylann | 2020-04-06 14:30

Oh right, that was it, was set to 1 :slight_smile:
Changed it, now it’s working, thank you

GreyMiller | 2020-04-06 14:35