+1 vote

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?

in Engine by (26 points)

1 Answer

+2 votes
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).

by (29,042 points)
selected by

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.