spaceship controls, help needed

I am making a space game in the vain of EVE or Freelancer and I am having a bit of difficulty.

I have a script based on Overwhelmed Arena
(I know this was for a “2D” game) with some
tweaking it works well, except now I need
the ship (currently just a rigidbody cube for simplicity/testing purposes) to be able to move
up and down following the mouse.

If you guys aren’t familiar with that script
its on Unify wiki I believe (if memory serves correct).

Any advice? I can post the entire script here if need be.

I searched the forums, if an answer exits and I overlooked it, I do apologize.

Thanks in advance.

Here is what you are looking for i think. It’s a Freelancer style mouse follow control.

http://forum.unity3d.com/viewtopic.php?t=28761&start=0&postdays=0&postorder=asc&highlight=

Thanks for the reply, I was searching for the wrong keywords I guess.

OK in order to get the UP and DOWN axis to work
with the spaceship, here is what I did:

MousePosition.z = (Screen.height/2) / Input.mousePosition.x;

The only bad thing is when LookatMouse is the only script ticked, it moves backwards away from planets rather than forward.

Here is the 2 scripts I am using, I want the player to be able to use the keyboard and the mouse to navigate the ship.

When ShipControls is ticked, it doesn’t allow movement UP and DOWN…

First script is this one:

var rSpeed = 1.0; // Scale. Speed of the movement 

function FixedUpdate () 
{ 
   MousePosition = Input.mousePosition; 
   MousePosition.x = (Screen.height/2) - Input.mousePosition.y; 
   MousePosition.y = -(Screen.width/2) + Input.mousePosition.x; 
   MousePosition.z = (Screen.height/2) / Input.mousePosition.x;
   transform.Rotate(MousePosition * Time.deltaTime * rSpeed); 
   transform.position += transform.forward * rSpeed * Time.deltaTime;
   
}

Then for the keyboard navigation I am using this script (shipControls.cs):

using UnityEngine;
using System.Collections;

// Put this on a rigidbody object and instantly
// have 2D spaceship controls like OverWhelmed Arena
// that you can tweak to your heart's content.

[RequireComponent (typeof (Rigidbody))]
public class ShipControls : MonoBehaviour
{
    public float hoverHeight = 3F;
    public float hoverHeightStrictness = 1F;
    public float forwardThrust = 5000F;
    public float backwardThrust = 2500F;
    public float bankAmount = 0.1F;
    public float bankSpeed = 0.2F;
    public Vector3 bankAxis = new Vector3(-0F, 0F, 0F);
    public float turnSpeed = 5000F;
    
    public Vector3 forwardDirection = new Vector3(0F, 1F, 0F);

    public float mass = 5F;
    
    // positional drag
    public float sqrdSpeedThresholdForDrag = 25F;
    public float superDrag = 2F;
    public float fastDrag = 0.5F;
    public float slowDrag = 0.01F;
    
    // angular drag
    public float sqrdAngularSpeedThresholdForDrag = 5F;
    public float superADrag = 32F;
    public float fastADrag = 16F;
    public float slowADrag = 0.1F;
    
    public bool playerControl = true;
    
    float bank = 0F;
		   
    void SetPlayerControl(bool control)
    {
        playerControl = control;
    }

    void Start()
    {
        rigidbody.mass = mass;
    }
    
    void FixedUpdate()
    {
        if (Mathf.Abs(thrust) > 0.01F)
        {
            if (rigidbody.velocity.sqrMagnitude > sqrdSpeedThresholdForDrag)
                rigidbody.drag = fastDrag;
            else
                rigidbody.drag = slowDrag;
        }
        else
            rigidbody.drag = superDrag;
                    
        if (Mathf.Abs(turn) > 0.01F)
        {
            if (rigidbody.angularVelocity.sqrMagnitude > sqrdAngularSpeedThresholdForDrag)
                rigidbody.angularDrag = fastADrag;
            else
                rigidbody.angularDrag = slowADrag;
        }
        else
            rigidbody.angularDrag = superADrag;
        
        transform.position = Vector3.Lerp(transform.position, new Vector3(transform.position.x, hoverHeight, transform.position.z), hoverHeightStrictness);
        
        float amountToBank = rigidbody.angularVelocity.y * bankAmount;

        bank = Mathf.Lerp(bank, amountToBank, bankSpeed);
        
        Vector3 rotation = transform.rotation.eulerAngles;
        rotation *= Mathf.Deg2Rad;
        rotation.x = 0F;
        rotation.z = 0F;
        rotation += bankAxis * bank;
        //transform.rotation = Quaternion.EulerAngles(rotation);
         rotation *= Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(rotation);
    }
    
    float thrust = 0F;
    float turn = 0F;
    
    void Thrust(float t)
    {
        thrust = Mathf.Clamp(t, -1F, 1F);
    }
    
    void Turn(float t)
    {
        turn = Mathf.Clamp(t, -1F, 1F) * turnSpeed;
    }
    
    bool thrustGlowOn = false;
    
    void Update ()
    {
        float theThrust = thrust;
        
        if (playerControl)
        {
            thrust = Input.GetAxis("Vertical");
            turn = Input.GetAxis("Horizontal") * turnSpeed;
        }
                
        if (thrust > 0F)
        {
            theThrust *= forwardThrust;
            if (!thrustGlowOn)
            {
                thrustGlowOn = !thrustGlowOn;
                BroadcastMessage("SetThrustGlow", thrustGlowOn, SendMessageOptions.DontRequireReceiver);
            }
        }
        else
        {
            theThrust *= backwardThrust;
            if (thrustGlowOn)
            {
                thrustGlowOn = !thrustGlowOn;
                BroadcastMessage("SetThrustGlow", thrustGlowOn, SendMessageOptions.DontRequireReceiver);
            }
        }
        
        rigidbody.AddRelativeTorque(Vector3.up * turn * Time.deltaTime);
        rigidbody.AddRelativeForce(forwardDirection * theThrust * Time.deltaTime);
    }
}

NOTE: Neither one of these are my scripts they are from the community, just modified slightly to do what I need it to do.

I am uncertain as how to setup the vectors,
I am fairly sure that is where my problem is.

Here are 2 examples, daskube is with both scripts
ticked, daskube2 is with only LookAtMouse ticked

I would have embedded it, but Google Sites do not allow that, so you will have to download the html and the unity package to view