Slaine
21-08-2008 16:01:48
Hi there, I'm after a way to slow a space ship down to a stand still, I basically don't want strict physics so I'm after a way of faking it by using some kind of slowing down physics routine. I've done before but in 2D using PhysLite, this was the method
So as you may see when you release the button it gets the velocity and reverses it until 0 is met, or standstill. Which works quite well.
Thanks.
m_velocity_x = m_power / m_mass;
m_velocity_y = m_power / m_mass;
m_x = -cos(m_angle) * m_velocity_x;
m_y = -sin(m_angle) * m_velocity_y;
if(keyDown(KEY_UP)){
m_body.MassAddVelocity(index2, m_x, m_y) ;
}
else
{
m_body.MassSetVelocity(index2, m_body.MassGetVX(index2), m_body.MassGetVY(index2)) ;
}
So as you may see when you release the button it gets the velocity and reverses it until 0 is met, or standstill. Which works quite well.
Thanks.