TL;DR How do I get the friggin' position of a Fixture from a libgdx Contact object?
1 2 3
| Contact col = cols.get(i); Entity entA = (Entity)col.getFixtureA().getBody().getUserData(); Entity entB = (Entity)col.getFixtureB().getBody().getUserData(); |
These are the first lines in my collision-code, the rest of which is otherwise unimportant and trivial.
I want to place an explosion in the middle of the fixture hit on my ship, if it is a killing shot.
As you can see, I can get the exact fixtures colliding from the Contact object, and they both may or may not be a part of a large body with many fixtures (in this case bullets and ships), and I can get the body it belongs to.
Problem: How do I find the position, or even better the middle, of the fixtures in my Contact object?I can put userdata into the fixtures, but since I use Aurelien's BodyEditorLoader, it loads a bunch of fixtures, from which I get no information. They are just created. What I CAN get, is the childIndexNumber, which I presume is the index of this child in it's parent Body's fixtureList. So I canget get almost any information from anywhere...but not the position.
Solutions:
- Hardcode every offset of every fixture into them after they're loaded... (sucks)
- ...