Reputation: 189
I am currently working on a project that requires a circular ring shaped body. How can I achieve this? I have tried to use a the convex-polygon
body with vertices similar to those of a circle but I am getting a The vertices specified do not match that of a _convex_ polygon.
error. How else can I make a ring shape?
Here is my current attempt:
var ring = Physics.body('convex-polygon',{
x: renderer.width* 0.35,
y: renderer.height *0.75,
vertices : [
{ x: -5, y: 0},
{ x: -3, y: 4},
{ x: -4, y: 3},
{ x: 0, y: 5},
{ x: 3, y: 4},
{ x: 4, y: 3},
{ x: 5, y: 0},
{ x: 3, y: -4},
{ x: 4, y: -3},
{ x: 0, y: -5},
{ x: -3, y: -4},
{ x: -4, y: -3}
]
});
Thanks in advance!
Upvotes: 1
Views: 67
Reputation: 3473
A ring shaped body is not convex, so that is the reason your model (assuming the vertices are correct) does not work. This old answer seems to suggest concave objects such as yours are not implemented in Physicsjs. This might have changed, but if not what you want is not possible.
EDIT: The link seems to have been broken. Fixed.
Upvotes: 1