Issues with your account? Bug us in the Discord!
Physics question -- how to steer a starship -- Take 3
croxis
I am the walrus
in Zocalo v2.0
lets pretend that you are playing a top-down tactical space ship game with Newtonian physics. You can click on the screen and your ship will turn to face that direction. Your ship has a mass and a maximum torque that the thrusters can put outt.
I figured out a method to apply the torque to a ship that is not rotating, but I can not figure out how to do it for a body that already has an angular velocity. So I am poking you very smart people to point me (pun intended) in the right direction.
For the curious the game engine I am using is Panda3D and the physics engine is Bullet.
I figured out a method to apply the torque to a ship that is not rotating, but I can not figure out how to do it for a body that already has an angular velocity. So I am poking you very smart people to point me (pun intended) in the right direction.
For the curious the game engine I am using is Panda3D and the physics engine is Bullet.
Comments
I'll have to do some thinking on (1).
I agree with Biggles because he has no face.
Hope this helps!
Also, [URL="http://www.amazon.com/Physics-Game-Developers-David-Bourg/dp/0596000065/ref=sr_1_1?ie=UTF8&qid=1360892909&sr=8-1&keywords=physics+for+game+developers"]this[/URL].
A little more detail: I'm working on a primitive navigation AI for ships with a predefined maximum torque (which can be increased or decreased by power levels, damage, etc but I digress). When the AI is given a desired heading and rotates the ship to point in that direction. In a simple example the ship has a heading of 0 and no rotation. The AI is given a target heading of 90 degrees. The AI then puts the torque to 100% until 45 degrees, then torque is put to -100% and the ship stops rotation at a heading of 90 degrees.
The problem I have is calculating when the switch to breaking should be.
Based on this time value, you can calculate how far the ship will rotate during this time. T = ut + 1/2*a*t^2. (Excuse the T for theta; I'm too lazy to grab the correct symbol.)
Now that you have the distance required to bring the ship to a stop, you can calculate what direction it should be pointing when braking should begin.
You may have noticed that these equations are like the linear velocity equations with different symbols; that's because they are.
Assuming I've got my basic physics right and haven't just made all that up, you should be able to do what you want using those equations. :)