# Creating my own flight physics?

Hi. I’m trying to make some realistic flight physics.

First… I’m trying to make the plane fly.

This is my aircraft:

What would be my best approach on making flight physics?

This is my current script:

``````	int curr_Speed;

float lift;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

curr_Speed = (int)(rigidbody.velocity.magnitude * 1 / 0.3f);

}

void FixedUpdate() {

}
``````

This only make the plane move forward (of course). What would be my next step and where should I apply rotation forces?

Andreas.

Probably u should try this script. . . .this is not really an advance script but just an example of where u can start

`````` //C# SCRIPT
public float maxSpeed;            // Our maximum speed allowed.
public float decAltSpeed;        //Decrease Altitude.
public float incAltSpeed;        // Increase Altitude.
public float curSpeed;            // Current Speed;
public float applySpeed;        // How much force to apply (Forward).

public float airBrakeForce;        // Breaks.

private Rigidbody myRigid;        // Our Rigidbody.

void Start(){
myRigid = GetComponent<Rigidbody>();        // Gets the players Rigidbody.
}

void FixedUpdate(){

curSpeed = myRigid.velocity.z;

if(curSpeed >= maxSpeed){
//If our speed maxes out to our maxSpeed we restrict our plane from going any faster.
applySpeed = curSpeed;
}

if(Input.GetKey(KeyCode.W)){
//Apply Accelleration
if(curSpeed >=incAltSpeed){
}

}
if(Input.GetKey(KeyCode.S)){
//Apply BREAKS
if(curSpeed <= decAltSpeed){
}
}

}

void Update(){
//NOT REALISTIC ROTATIONS

//You may have to move the '-' sign to the other one (- means opposite) E.G. - Negative so I THINK -Vector.up is left. Could be wrong though.

if(Input.GetKey(KeyCode.A)){
transform.rotate(-Vector3.up * 15 * Time.deltaTime);

}
if(Input.GetKey(KeyCode.D)){
transform.rotate(Vector3.up * 15 * Time.deltaTime);

}
}

}
``````

hope u can get a idea

If you want to do it well, you’ll probably have to consider lift and downforce to the wings (depending on velocity and pressure) and variable gravity (depending on distance): g=G*Mearth/(radius+heightfromwater)^2
You should try implement windzones and high/low pressure zones

If you calculate all of this into separated vectors, you can finally sum all together and get the resulting force applied to the aircraft