Wind resistance

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

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.

mcaden

21-08-2008 16:16:36

There's wind in space? 0.ô


Anyway, I think you can find the code if you look at some of the vehicle threads. They use basically the same concept.

Slaine

21-08-2008 16:20:11

There's wind in space? 0.ô


Anyway, I think you can find the code if you look at some of the vehicle threads. They use basically the same concept.

Well yeah I know but you know what I mean :D

This is what I thought but then you'll get the problem of the ship rolling over won't you? I'm asuming you mean create a ground to slide on?

mcaden

21-08-2008 16:33:38

I think you're not understanding what I said.

This should do sorta what you're looking for I think:
myActor->setLinearVelocity(-myActor->getLinearMomentum() / 2);

Slaine

21-08-2008 16:44:26

I think you're not understanding what I said.

This should do sorta what you're looking for I think:
myActor->setLinearVelocity(-myActor->getLinearMomentum() / 2);


Great! It worked, I was kind of doing what you said but, it needs to be setLinear and getLinear and it has to have / 2, I wouldn't of got that :S

Thanks a lot :wink: