How to make an epllise collider ? #890
Unanswered
JJJJJJJustin
asked this question in
Q&A
Replies: 2 comments 3 replies
-
|
You can't. Circles have the same radius all round and there is no Ellipse shape in Box2D. The closest you could get would be a capsule, or a polygon - but be aware that the maximum number of polygon vertices is 8, so if you need it to be smoother than that, you'll need multiple polygons. |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
You can probably create something close to an ellipse using a rounded polygon shape. Maybe a diamond shape with a radius. b2Vec2 points[8] = {
{ 0.0f, -0.25f }, { 0.0f, 0.25f }, { 0.05f, 0.075f }, { -0.05f, 0.075f }, { 0.05f, -0.075f }, { -0.05f, -0.075f }, { 0.05f, 0.0f }, { -0.05f, 0.0f },
};
b2Hull diamondHull = b2ComputeHull( points, 8 );
b2Polygon poly = b2MakePolygon( &diamondHull, 0.3f ); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
How do I create an ellipse collider in box2d?
I was recently using box2d and I created a standard circle collider for a circle, but once I changed the scale of the circle (to visually make it look more like an ellipse), I couldn't get realistic physics simulation for the ellipse because its collision mode was still based on the standard circle, and I couldn't figure out how to design an ellipse collider.
(from a novice programmer)
Beta Was this translation helpful? Give feedback.
All reactions