13

我有一个质量为 10 的物体,程序的每个循环我使用简单的方法对其施加 100 的力;

Vector2 force = new Vector2(0, 1) * 100;
bod.ApplyForce(force, bod.GetWorldCenter());

It works great, accelerates and all of that, but once it gets to a velocity of 10 (100 / 10 I assume) it won't go any faster. I am not a physicist by any means, but I do recall that the body should continually accelerate, like it would under gravity. Is this speed limit a result of the way Box2D does things, or am I royally screwing something up ? Also, what do I do to fix it.

NOTE: I get the same limited velocity if I use ApplyLinearImpulse instead of ApplyForce

Update: I am well aware of the overall max speed limit imposed by Box2D (in b2Settings.h). In my example, the item in question is moving well below this limit as changing the appplied force, be it 1000 or 10000 will always come around to the max velocity of (force / mass).

4

1 回答 1

4

您正在达到物体的最大允许速度。有两种方法可以解决此问题:

  1. 在 Box2D 设置中调整最大允许速度;打开设置并将MaxTranslationfloat/const 更改为更高的值,我假设它是默认的2.0.

  2. 缩小对象大小,执行必要的计算,放大对象。这是技术上正确的做法,正如 Box2D 的注释MaxTranslation

物体的最大线速度。此限制非常大,用于防止出现数值问题。您不需要对此进行调整。

所以尝试#1,如果这确实有效,那么这意味着你可能需要扩展。希望有帮助。

于 2013-03-19T18:59:45.610 回答