开发者

Box2D: How to get the position of a static body?

I have a Box2D world with a mixture of static and dynamic bodies. On collisions, I can only get the positi开发者_如何学Cons of the dynamic ones.

Is it possible to get the positions of static objects?

N.b., this is a development of a previous question, Box2D: How to get the position of a sensor?


I found a way - in the collision, the center of the AABB will give the position

contact.GetFixtureA().GetAABB().GetCenter()


You can get the position vector using the following code:

b2Transform t = body->GetTransform();
b2Vec2 pos = b2Vec2(t.p.x,t.p.y);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜