2
$\begingroup$

I'm trying to create a logic brick setup for a flight simulation of an airplane.

It shouldn't be too realistic as the purpose is to create a fun little game. (would be great though!)
There should be some 'real world like' physics involved (like gravity) because crashing is definitely something I would like to achieve. Even struggling with a basic setup and countless hours trying different things I feel kind of stuck on this problem.

$\endgroup$
2
$\begingroup$

Airplane physics is a little bit tricky as you need to consider what makes the plane "not fall from sky" = the forces that lift the plane up.

Counter gravity

The simplest solution is to completely ignore the gravity. You assume there is always a force that counters it:

-> Motion Actuator Force[0, 0, 9.8] not local

Constant up force

Another simple solution is to assume there is always a force that drags the plane along it's z-axis. This would be plausible if the plane is travelling with constant speed.

-> Motion Actuator Force[0, 0, upForce] local

The upforce should be somewhere above gravity. This will lift up the airplane when flying parallel to ground. As less parallel the plane is as less global upforce it will get.

Speed dependent upforce

This is more plausible. We know that a plane without speed will fall like a stone. We also know that as higher the speed is as stronger the (local) upforce is due to the airpressure at the wings.

We really do not want to simulate airpressure in a simple game. So we just assume certain forces at certain forward speed. Due to it's dynamic nature you will need some Python to calculate that.

E.g.

import bge

CONVERSION_FACTOR = 0.1

owner = bge.logic.getCurrentController().owner
velocity = owner.localLinearVelocity
ySpeed = velocity.y

# enter your formula here
upForce = ySpeed * ySpeed * CONVERSION_FACTOR

owner.applyForce((0, 0, upForce))  
  • The above solution expects the plane to travel along Y.
  • The given formula will result in very high upforce on high speed (which is not plausible on a plane). It is up to you to find a fitting formula.
  • Have a look at the physics damping that the plane will loose speed without engines
  • trigger the controller with an Always sensor with enabled [True Level Triggering]

I hope it helps

$\endgroup$
2
$\begingroup$

Your could add a sensor for the up w key(pulse mode(the first " button)) and then connect to a simple movement actuator that will move it in its forward local direction. Then you could use the mouse sensor and connect it to the mouse look actuator to steer the plane. You could also try to prevent it from falling by connecting your w key sensor to another simple motion that adds a force of 9.8 (m/s) on the z axis. This should cancel out the gravity. Don't forget to set the plane's physics to dynamic or rigididy.

While this is simple, it's terrible. The plane has no acceleration. It's either fully stopped or top speed. It will also fall if you let go of the w key.

If you want something better, Python scripting is the way to go. The movement will be able to be lerped (linear interpolation. In other words, get from one number to another gradually, like a gradient, in a certain amount of time, to simulate acceleration. You could also simulate "lift" by multiplying a "liftStrength" float variable with your current velocity (or speed), then apply that number to an applyForce on the z axis. This will make it to where when you're plane is moving fast enough, it will generate lift.

Still, even his isn't good enough as when you got upside down or sideways, it just gets weird. Still, you can make very realistic planes in Python, but it requires a LOT more code and knowledge.

Also, just to point this out, Python isn't hard. It's one of the easiest.

Here, click this link to get started in blender game engine Python scripting:

Blender Game Engine Python Tutorial Series: http://www.youtube.com/playlist?list=PL6F4A5BAADFFADA2E

I cannot give you a definitive answer, because the question is a bit too broad, but this is just my two cents.

$\endgroup$
  • $\begingroup$ Thank you for your answer. It helped me out a lot. It's people like you that make this platform great! $\endgroup$ – Delagone Mar 15 '16 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.