I am creating enemies using a program where I specify the position of all the vertices. I can use vertices, square, or circles. The final geoms look exactly like they should but there is just one problem. All bodies are offcentered.
Here are some images showing it:
Here you can see that the body is positioned to low.
Here the body is positioned to high!? (Both of these problems use the exact same code)
Here is how it looks when combined. It's not huge but it needs fixed. Also you can see a little bit of the other enemy how his is also not positioned correctly. He uses the Rectangle code I have.
Here is what it should look like. This is from the program I am using.
Why are the bodies not in their correct positions? I thought it maybe how they are centered by centroid but still doesn't work.
Here is my code for the polygon objects.
PathItem pItem = (PathItem)item;
Vertices vertices = new Vertices(pItem.LocalPoints);
Vector2 relPosition = pItem.Position + vertices.GetCentroid();
tempBody = BodyFactory.Instance.CreatePolygonBody(Farseer.Physics, vertices, mass);
tempGeom = GeomFactory.Instance.CreatePolygonGeom(Farseer.Physics, tempBody, vertices, -1f);
//Set position using LevelMaker.GetCenter(vert)
//TODO: Consider putting this in its own special class
tempBody.Position = this.position + relPosition;
this.position is the world position and relPosition should be the body position. I bet it still has something to with centroid but I don't know what to do. Any help is very appreciated :)