Flight movement on a Terrain

Started by
1 comment, last by Kenneth 20 years, 7 months ago
Hi folks I''m trying to make a flight game, you are controllning a ship flying above a Terrain. I have trouble with the flight engine, can''t seem to get the movement correct =/, would need some math formula help. Small code parts would be helpful (programming language don''t mather). Problem: Lets say the ship data is position 50,20,20 (X,Y,Z) Angels 0,0,0 (X,Y,Z) MoveSpeed 2 at this point the ship is just moving forward in the terrain. Then i press some keys witch change the angles to 10,10,0. The ship should now be moving some units up and some units to right or left, and some uits forward, how do i calculate the movement ? Thanks in advance.
Advertisement
well, you need a bit physics to get your ship moving.

you also need an orientation matrix for your ship. That would be helpful.


Vector Position;Matrix Orientation;float  EnginePower;//.....//.....//.....void Update(float dt){    // rotate the ship given a set of controls    Vector RotationAngle;    RotationAngle.x = ((KeyPressed(''s'') - KeyPressed(''w''));    RotationAngle.y = ((KeyPressed(''<'') - KeyPressed(''>''));    RotationAngle.z = ((KeyPressed(''d'') - KeyPressed(''a''));    RotationAngle.x *= MaxPitchVelocity * dt;    RotationAngle.y *= MaxYawVelocity   * dt;    RotationAngle.z *= MaxRollVelocity  * dt;    Matrix Rotation;    Rotation.FromEuler(RotationAngle); // convert from euler angles to a matrix    Orientation = Rotation * Orientation; // update the orientation of the ship    Vector Dir = Vector(Orientation.e13, Orientation.e23, Orientation.e33); // new direction of travel of the ship    Position += Dir * (EnginePower * dt); // move the ship forward}


Something in that vein would work.

Everything is better with Metal.

Thx for fast awnser, i''ll try to make it work =)

This topic is closed to new replies.

Advertisement