Simple Flight Simulator?

Blitz3D Forums/Blitz3D Beginners Area/Simple Flight Simulator?

jeffmorris(Posted 2006) [#1]
How do I write a simple flight simulator? There is "XFighter" program in the "Samples" folder but the airplane doesn't behave like a real one. Here is part of my program:

  throttle=(JoyU(0)-1) * -0.5
  If (throttle > 0.1 And JoyX(0) < -0.1) Then TurnEntity camera,0,-JoyX(0),0
  If (throttle > 0.1 And JoyX(0) > 0.1) Then TurnEntity camera,0,-JoyX(0),0
  If (throttle > 0.1 And JoyY(0) < -0.1) Then MoveEntity camera,0,JoyY(0),0
  If (throttle > 0.1 And JoyY(0) > 0.1) Then MoveEntity camera,0,JoyY(0),0
  If throttle > 0.1 Then MoveEntity camera,0,0,throttle


I couldn't get the airplane (camera) to fall to the ground if the throttle is set at 0.


Weetbix(Posted 2006) [#2]
You need a constant like gravity , that pulls down on your plane so every loop you would call

 translateentity camera,0,gravity,0 


It doesnt really matter what value gravity is just set it to something that works for you.


Matty(Posted 2006) [#3]
A fairly simple method would be to do this, although I don't know how realistic it would be:

The following forces apply to the plane at any one time:

Force of Gravity (mass*acceleration due to gravity) (always towards ground)
Force of Lift (due to flow of air over wings, proportional to forwards velocity of aircraft and always in the 'up vector' relative to the aircraft)
Force of Friction (due to air resistance - dependent upon the square of the velocity and the cross sectional area of the moving object perpendicular to the direction of movement - a simple constant should suffice multiplied by the velocity of the aircraft squared)
Force of Thrust (due to propeller/jet etc in direction 'forwards' relative to aircraft.)

Then combine these forces by adding them together (vector addition so you will get components in each direction x,y,z) and apply the force to the aircraft as an acceleration to the aircraft.

Play around with something like that to get started, otherwise there should be plenty of information online on how to simulate aircraft motion.


Andy(Posted 2006) [#4]
Very good explanation Matty, although there is one very critical error.

>Force of Lift (due to flow of air over wings, proportional
>to forwards velocity of aircraft and always in the 'up
>vector' relative to the aircraft)

should be:

Force of Lift (due to flow of air over wings, proportional
to forwards velocity of aircraft and always in the 'up
vector' perpendicular to the direction of movement)


Andy


Matty(Posted 2006) [#5]
You are right Andy, my mistake.