I created a body(rectangle). After that, I attached a circle shape to the body.

I need the position(world coodinates) of the circle shape because I want to draw a circle sprite(Texture2D) on that position.

How can I get the world coodinates of the fixture?

Body Rectangle;
Rectangle = BodyFactory.CreateRectangle(world, 1.50f, 0.50f, 1.0f);
Rectangle.BodyType = BodyType.Static;
Rectangle.Position = new Vector2(4.8f, 6.4f);
Rectangle.Rotation = (float)(60 * Math.PI / 180);

CircleShape = new FarseerPhysics.Collision.Shapes.CircleShape(0.5f, 1.0f);
CircleShape.Position = new Vector2(1.0f, 0.0f);
Fixture fixture = Rectangle.CreateFixture(CircleShape, 1.0f);

You have to get the position of the fixture's body.

Vector2 position = fixture.Body.Position;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.