I have a jumping game. There are some items that when the jumper collects then it stays in the air for 3 seconds and then falls down. For that I have done the following:
// to stop the body in the air
body->SetGravityScale(0);
body->SetLinearDamping(7); // don't want abrupt stopping
To make body to fall again from the air back to the ground after 3 seconds I do:
body->SetGravityScale(1);
body->SetLinearDamping(0);
But it continues to stay in the air. Only when I apply a small impulse towards down it starts to fall. Why?
EDIT: I have explicitly set:
m_world.SetAllowSleeping(false);
but anyways, I should apply linear impulse to make him fall back or simply do:
body->SetAwake(true);
It turns that body is sleeping even if m_world.SetAllowSleeping(false);
. Is this OK?
m_world.SetAllowSleeping(false);
on debug draw it really slept when I setbody->SetGravityScale(0);
. I have explicitly setm_world.SetAllowSleeping(false);
and it worked withoutbody->SetAwake(true);
. Seems something when wrong with compilation and it did not update the executable. – Narek