Velocity cap

micken

11-07-2008 11:12:20

Hi. I have an object that is floating around in a simulated zero-g environment on the XZ plane. The user can press forward to push the object forward and rotate it with the arrow keys. I am trying to figure out the best way to implement a velocity cap in the object's forceandtorquecallback. Does anyone have any suggestions how to accomplish this?

Thank you!

walaber

11-07-2008 14:05:06

only allow them to add movement force in a given direction if the current velocity in that direction is below your cap value...

micken

11-07-2008 19:27:28

Sorry, I forgot to explain that my forceandtorquecallback moves the ship forward by applying a small amount of force each frame as the up arrow is held down. I suppose it would make sense though to make sure the ship's velocity vector length is less than my cap before applying the force. How would I calculate the exact amount of force to apply so that the velocity vector length hits the cap exactly?

Thanks!

walaber

11-07-2008 19:50:34

force = ((goal_velocity - current_velocity) / desired_time_to_reach_goal) * mass