开发者

box2d: GetLinearVelocity() to detect motion?

开发者 https://www.devze.com 2023-02-26 07:22 出处:网络
Pretty simple question: will the result of b2Body::GetLinearVelocity tell me if an object is in motion? I would expect that it w开发者_Python百科ould - does it?GetLinearVelocity() returns a b2Vec2. Yo

Pretty simple question: will the result of b2Body::GetLinearVelocity tell me if an object is in motion? I would expect that it w开发者_Python百科ould - does it?


GetLinearVelocity() returns a b2Vec2. You could use b2Vec2::Length() to find the magnitude of the velocity; if it is zero, the object is not moving.


It would tell you if the body is moving. However it could also happen to be spinning in one place around the origin and getLinearVelocity() would return zero. So if you want to be definitely sure that no motion is happening you should check getAngularVelocity() as well.

0

精彩评论

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

关注公众号