Smooth Space Flight Script

Hello everyone, my name is Grey Walker.

I am looking for a script or scripter capable of making Eve-like space navigation. More specifically like Battlestar Galactica Online.

the functions would be right clicking in any forward direction, the ship or player tilts towards the direction and moves in that direction. The ship does not stop.

the movement speed is determined by a gui slider, but the ship does not move to a point, only moves in that direction.

If you know of a script that would aid me in this, or are able to yourself, write such a script, i would be very appreciative, and would add you to the credentials of my game.

notes:

Right click to make ship tilt and move in that direction.
A secondhand GUI slider determines the speed of the ship, from high speed, to a stop.
The ship must slowly turn towards the direction.

If you need reference, i urge you to research the movement controls displayed in Battlestar galactica online, which was made in unity.

This code will give the relevant movement and camera controls using double click to move and right click to rotate camera… Only thing i would like is a bit better response to the position of the double click… maybe also a faster rotate to response to the click…

anyways HEREs a beter starting point… Thank FORCEX for this code

var PlayerCamera : Transform;

private var ThisTransform : Transform;

 

var CameraOffset : Vector3 = Vector3(0,3,10);

var CameraSpeed : int = 200;

 

var yMinLimit = -90;

var yMaxLimit = 90;

 

private var MouseInput : Vector2;

private var directionTurn : Vector3;

private var singleClick : boolean = false;

private var count : int;

private var Turn : boolean;

private var cTimer : float;

var doubleClickTime : float = .5;

 

function Start () {

ThisTransform = transform;

    PlayerCamera.eulerAngles = Vector3(0, 0, 0);

    PlayerCamera.position = Vector3(ThisTransform.position.x, ThisTransform.position.y + CameraOffset.y, ThisTransform.position.z - CameraOffset.z);

}

 

function Update () {

 

ThisTransform.Translate(Vector3.forward * 5 * Time.deltaTime);

 

    if(Input.GetMouseButtonDown(0)){

        var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        singleClick = true;

        count ++;

    }

 

    if(singleClick == true){

        cTimer += Time.deltaTime;

        

        if(count >1){

            directionTurn = ray.direction * 500;

            Turn = true;

            singleClick = false;

            count = 0;

            cTimer = 0;

        }

    

        if(cTimer >= doubleClickTime){

            count = 0;

            singleClick = false;

            Turn = false;

            cTimer = 0;

        }

    }

 

        if(Turn){

            var Rotation = Quaternion.LookRotation(directionTurn - ThisTransform.position);

            ThisTransform.rotation = Quaternion.RotateTowards(ThisTransform.rotation, Rotation, Time.deltaTime * 20);

            ThisTransform.eulerAngles.z = 0;

        

            var targetDir = directionTurn - transform.position;

            var forward = transform.forward;

            var angle = Vector3.Angle(targetDir, forward);

        if(angle < 0.05){

            Turn = false;

        }

    }

}

 

function LateUpdate(){

UpdateCamera();

}

 

function UpdateCamera () {

 

var rot : Quaternion = Quaternion.Euler(MouseInput.y, MouseInput.x, 0);

var pos : Vector3 = rot * Vector3(0.0, CameraOffset.y, -CameraOffset.z) + ThisTransform.position;

    

    if(Input.GetMouseButton(1)) {

        MouseInput.x += Input.GetAxis("Mouse X") * CameraSpeed * Time.deltaTime;

        MouseInput.y -= Input.GetAxis("Mouse Y") * CameraSpeed * Time.deltaTime;

        MouseInput.y = ClampAngle(MouseInput.y, yMinLimit, yMaxLimit);

    }

 

PlayerCamera.position = pos;

PlayerCamera.rotation = rot;

}

 

static function ClampAngle (angle : float, min : float, max : float) {

    if (angle < -360)

        angle += 360;

    if (angle > 360)

        angle -= 360;

    return Mathf.Clamp (angle, min, max);

}