Box2D的:如何获取静态物体的位置?物体、静态、位置、Box2D

2023-09-08 12:44:20 作者:微信扫描或直接搜索关注“腾牛个性网”微信公众号,方便随时查看

我有一个box2d的世界与静态和动态体的混合物。在碰撞,我只能得到动态的的位置。

I have a Box2D world with a mixture of static and dynamic bodies. On collisions, I can only get the positions of the dynamic ones.

时有可能得到静态物体的位置?

Is it possible to get the positions of static objects?

NB,这是一个发展的previous问题的 Box2D的:?如何获取传感器的位置

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

推荐答案

您可以使用下面的code得到的位置矢量:

You can get the position vector using the following code:

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