My problem is that my Farseer bodies are not matching the position of the texture. There’s a little offset and I’ve no idea why that’s happening. I wanted to ask if someone has an idea how to solve it or experienced something similar to that.
Video: https://www.youtube.com/watch?v=trSpsO0mJH0
I’m using MonoGame: 3.5, Farseer: 3.5
Thanks
class TestActor
{
Body rigidbody;
Texture2D texture;
Vector2 position = new Vector2(6.5f, 0f);
public TestActor()
{
// texture = Game1.content.Load<Texture2D>("Sprites/tileset");
texture = Game1.content.Load<Texture2D>("Test/box");
ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);
rigidbody = BodyFactory.CreateRectangle(Game1.world, ConvertUnits.ToSimUnits(texture.Width), ConvertUnits.ToSimUnits(texture.Width), 1.0f, position);
rigidbody.BodyType = BodyType.Dynamic;
rigidbody.Restitution = 0.3f;
rigidbody.Friction = 0.5f;
rigidbody.CollidesWith = Category.All;
}
public Body body
{
get { return body; }
}
public void Update()
{
//rigidbody.ApplyForce(new Vector2(2, 2));
//Console.WriteLine(ConvertUnits.ToDisplayUnits(rigidbody.Position));
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, ConvertUnits.ToDisplayUnits(rigidbody.Position), null, Color.White, rigidbody.Rotation,
new Vector2(texture.Width / 2.0f, texture.Height / 2.0f), 1f, SpriteEffects.None, 1f);
}
}