Airplane Script Control

I need help with my airplane script. my airplane wont move at all so can anyone see the problem with it

var throttle : int = 0;
var currentSpeed : float = 0.00;
var maxSpeed : float = 0.00;
var maxAltitude : float = 100.00;
var currentAltitude : float = 0.00;
var gravity : float = 200.0;

private var moveDirection : Vector3 = Vector3.zero;
var aircraftCtrl : CharacterController;

function Start(){
maxSpeed = calculateMaxSpeed(throttle);
}

function Update(){

currentAltitude = transform.position.y;

// Listen for input key entry
if(Input.GetButtonDown("ThrottleUp"))
{
    if(throttle < 10)
    {
        throttle++;
    }
    maxSpeed = calculateMaxSpeed(throttle);
}

if(Input.GetButtonDown("ThrottleDown"))
{
    if(throttle > 0)
    {
        throttle--;
    }
    maxSpeed = calculateMaxSpeed(throttle);
}

    if(currentSpeed < maxSpeed)
    {
        currentSpeed = currentSpeed + 0.05;
    }
    if(currentSpeed > maxSpeed)
    {
        currentSpeed = currentSpeed - 0.02;
    }

    if(currentSpeed > 40)
    {
        maxAltitude = 2 * (throttle * 10);
    }
    else
    {
        maxAltitude = 1.00;
    }
if(currentSpeed > 3 && currentSpeed < 40)
{
    moveDirection.y -= (gravity / 100) * (Time.deltaTime / 50);
    aircraftCtrl.Move(moveDirection * (Time.deltaTime / 30));
}

if(currentSpeed > 40 && currentAltitude <= maxAltitude)
{
    moveDirection.y = gravity * (Time.deltaTime / 5);
    aircraftCtrl.Move(moveDirection * (Time.deltaTime / 3));
}

Move function(){
    moveDirection.x = (currentSpeed * (Time.deltaTime)) * 3;
    aircraftCtrl.Move(moveDirection * Time.deltaTime);
}
    print("Throttle Position: " + throttle + " Current Speed: " + currentSpeed + 
    " Max Altitude: " + maxAltitude + " Altitude: " + currentAltitude + " Gravity: " + 
    moveDirection.y);
}

function calculateMaxSpeed(throttle)
{
    if(throttle == 0)
    {
        maxSpeed = 0.00;
    }
    else
    {
        maxSpeed = throttle * 10;
    }
    return maxSpeed;
}

A few ideas for you.

  1. I don't know if you dragged the character controller to the aircraftCtrl variable.

  2. I didn't see anything that called this function in your code:


    Move function(){ moveDirection.x = (currentSpeed * (Time.deltaTime)) * 3; aircraftCtrl.Move(moveDirection * Time.deltaTime); }


Controller.Move is calling its own version of the function so maybe you were trying to override it? I would appear that you are trying to cause the motion with this function, but you are never calling it. To call it, all's you have to do is say `Move()` instead of a`ircraftCtrl.Move()`.

This might be the most important piece. Character Controllers are not designed for planes so I would not recommend using one. A mesh collider with a rigidbody or box collider would give you more realistic results.

To get your code to work you need to apply forces to your object. This is done via a manipulation to one or more rigid bodies.

There is a ton of resources on this in the forums. Just do a search for "airplane" or "Aircraft" or biplane.

http://forum.unity3d.com/viewtopic.php?t=52967&highlight=aircraft