Perfect Circle Collision Shape in 2D Engine

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

I’m currently working on a little mobile game, making use of the RigidBody2D Engine. However, the RigidBody’s collision shape is supposed to be a circle, but Godot only offers a circle-like shape which is actually a 24-corner shape. As a result, the RigidBody does not roll like a normal Ball would do, it rather slides down slopes without rotating.
Does anyone know a solution in order to get a perfect circular collision shape?

:bust_in_silhouette: Reply From: Zylann

AFAIK, CircleShape2D is not a polygon shape made of 24 segments. Where did you see this?
The debug visual surely is composed of 24 segments because graphics card use polygons to draw things, so it happens that the visible disk shows edges.
But in the 2D physics engine, it really uses a circle formula to solve collisions. You can verify this by angling a circle by 1 degree: if it was a 24-edge circle, it would have slowly shifted to the right, as it would induce a small desequilibrium. But that does not happen, rotation remains 1 degree.

I did some tests with just a circle body and a platform. First thing I had to check is the body being put to sleep. The physics engine estimated it was not moving enough to bother simulating it, so it freezes the body.
This can be fixed by unchecking can sleep in the inspector.

After that, I can see the circle rotate as it slides down a slope. It correctly rotates even very slowly on a slope angled at 1 degree only.

If it slides but doesn’t rotate, you may have to check its angular damping, or if something else sets its rotation (which you shouldnt do).

Thank you very much!
The angular damping indeed fixed it, sorry for my stupid guess about the 24-corner.

Blackthorn | 2020-04-08 12:45