Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 box2d 世界中有一个身体(玩家)。
每当我尝试设置它的 x 速度(每 2 秒或其他)并且它由于重力而下降时,它会上下抖动。
我还尝试将它的 y 速度设置为等于重力(-30.0f),但它做得更糟。
特维姆。
那是因为你的玩家被创建为一个动态的身体。因此,重力会在每个模拟步骤中应用到玩家身上,从而导致他/她改变速度。
放置您的播放器b2_kinematicBody- 然后不会对其施加任何力。如果您仍然希望玩家在-playerMass*gravityVector每一步都动态施加力(或将 b2World 的 autoClearForces 参数设置为 false 并施加一次力)以消除重力。
b2_kinematicBody
-playerMass*gravityVector