我有一个球(圆形的动态物体),它在重力条件下作用在表面(蹦床)上。
当球撞击蹦床(图中从 A 点到 B 点绘制)时,我想向球施加一个脉冲(垂直于蹦床表面)。
![enter image description here](https://i.stack.imgur.com/TCR8e.png)
问题是现在我使用:
b2Vec2 impulse = b2Vec2(0, [self fullMass]*[GameMaster sharedInstance].usrTrampolineForce);
b2Vec2 impulsePoint = _body->GetWorldPoint(b2Vec2(0/PTM_RATIO, -1.0/PTM_RATIO));
_body->ApplyLinearImpulse(impulse, impulsePoint);
它将球垂直(在表面上)向上(图中的红色方向)发送,尽管它应该遵循一定的现实轨迹(用黑色绘制)。
我怎样才能运用冲动来进行真实的跳跃?
即请注意,我对球相交的所有情况感兴趣。例如,球可能落在蹦床上,但球仍应具有正确的轨迹。
我不读 Objective-C,但问题似乎很清楚:
你的冲动b2Vec2(0, [self fullMass]*[GameMaster sharedInstance].usrTrampolineForce)
实际上不包含任何 x 组件!
将脉冲分成 x 和 y 分量(伪代码):
Impulse_magnitude = Ball_mass * Trampoline_Force
# theta is the angle between the horizontal and your impulse
# this will depend on the angle of the trampoline.
Impulse_x = Impulse_magnitude * Cos(theta)
Impulse_y = Impulse_magnitude * Sin(theta)
# Create your impulse vector
Impulse_v = b2Vec(Impulse_x, Impulse_y)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)