Flight Control/Banking

I have a ship flying in a zero g environment. I have a problem. The problem is that I need to make the ship bank. When I turn, it makes the ship loo unrealistic. The ship follows the mouse, so by pressing forward and moving the mouse to the right, the ship turns to the right & vice versa. But the ship doesn’t bank. Is this even possible to do?

This is the only way I could find out how to do this. It works but it’s not efficient. I wanted the ship to follow the mouse, but the ship itself would not follow the mouse, but if I put the script on the camera it would. So what I did was make ship “follow” the camera, but made the follow value negative, therefore putting the camera in front. I don’t think there are banking answers if this is the way I’m doing it. Is there an even more efficient way to make space flight control? Then maybe the banking answers will work.

The best way is to have two objects: an empty object to move around, and a child object to do the banking - your model or the first person camera will be attached to this child object. This way the banking will not interfere with the movement, and you can bank sideways and back/forth without any problem.

You can find a similar question with all details about how to do this here.

EDITED: Do the following:

1- Create an empty object and name it “Model”;

2- Drag this object to your spaceship (to make it a spaceship child);

3- Zero its rotation and position;

4- Drag your model to this object;

5- Attach the script below to this object;

function Update(){
    var v = Input.GetAxis("Vertical"); // use the same axis that move back/forth
    var h = Input.GetAxis("Horizontal"); // use the same axis that turns left/right
    transform.localEulerAngles.x = v*15; // forth/back banking first!
    transform.localEulerAngles.z = -h*15;  // left/right

This script just observes the same axes you use to move the spaceship, and banks according to their values - if you use Input.GetAxis(“Mouse X”) to turn left/right, for instance, substitute the “Horizontal” name above with “Mouse X”.

The spaceship should be an empty object, with the object Model childed to it, and the model itself childed to Model. Your camera target should be set to the spaceship object - as it is already, I suppose.

First of all thanks to @aldonaletto for a good solution. For those weary travelers who find themselves here, looking for a basic solution. Here is my version of the idea suggested above with regards to separating the movement from the banking and which seems to work fine, at least for now. This code was is for a basic game where you control a mosquito and I wanted the insect to bank as it moved from left to right for a bit more realism, and as stated, using this code it now does so.

The structure is exactly as suggested above with parent and child objects and with the respective scripts attached to each of those objects.

PlayerController Script

 void HandleInput()
        horInput = Input.GetAxis("Horizontal");
        vertInput = Input.GetAxis("Vertical");

        //rb.AddForce(Vector3.right * speed * horInput);
        //rb.AddForce(Vector3.forward * speed * vertInput);

        transform.Translate(Vector3.right * speed * horInput * Time.deltaTime);
        //transform.Translate(Vector3.up * speed * vertInput * Time.deltaTime);

BankingController Script

void HandleInput()
        horInput = Input.GetAxis("Horizontal");

        z = -horInput;

        //modifying the Vector3, based on input multiplied by speed and time
        currentEulerAngles += new Vector3(0, 0, z) * Time.deltaTime * rotationSpeed;

        //moving the value of the Vector3 into Quanternion.eulerAngle format
        currentRotation.eulerAngles = currentEulerAngles;

        //apply the Quaternion.eulerAngles change to the gameObject
        transform.rotation = currentRotation;

Hope someone finds this useful.