0 votes

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?

asked Apr 8 in Engine by Blackthorn (25 points)

1 Answer

+1 vote
Best answer

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

answered Apr 8 by Zylann (26,157 points)
selected Apr 8 by Blackthorn

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

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.