Banking and Rotating a plane problem

I’m attempting to make a plane bank while it turns. I’ve tried the two lines below and not having any luck.
Thanks for your help.

transform.rotation = Quaternion.Euler (transform.velocity.x * -tilt, 0.0f, 0.0f);
//player.transform.rotation = Quaternion.Euler (player.velocity.x * -tilt, 0.0f, 0.0f);

using UnityEngine;
using System.Collections;

public class MovePlane : MonoBehaviour
{
    //public float speed;
    // Use this for initialization
    public float speed;
    public float rotationSpeed;
    public float tilt;
    public GameObject player;
    public Rigidbody rplayer;
    void Start ()
    {
   
    }
   
    // Update is called once per frame
    void FixedUpdate ()
    {
       
        // Get the horizontal and vertical axis.
        // By default they are mapped to the arrow keys.
        // The value is in the range -1 to 1
        float translation = Input.GetAxis ("Vertical") * speed;
        float rotation = Input.GetAxis ("Horizontal") * rotationSpeed;
           
        // Make it move 10 meters per second instead of 10 meters per frame...
        translation *= Time.deltaTime;
        rotation *= Time.deltaTime;
           
        // Move translation along the object's z-axis
        transform.Translate (-translation, 0, 0);
        // Rotate around our y-axis
        transform.Rotate (0, rotation, 0);
        transform.rotation = Quaternion.Euler (transform.velocity.x * -tilt, 0.0f, 0.0f);
        //player.transform.rotation = Quaternion.Euler (player.velocity.x * -tilt, 0.0f, 0.0f);
    }
}

First of all,

transform.Rotate (0, rotation, 0);

followed by

transform.rotation = Quaternion.Euler (transform.velocity.x * -tilt, 0.0f, 0.0f);

doesn’t make much sense.

transform.Rotate() modifies the transform.rotation property.
transform.rotation = … sets the property to a new value.

So, the changes made by transform.Rotate() in line 35 are lost.

Second, the transform component has no velocity property. So

transform.rotation = Quaternion.Euler (transform.velocity.x * -tilt, 0.0f, 0.0f);

can’t work.

Are you looking for Unity - Scripting API: Rigidbody.velocity?

transform.rotation = Quaternion.Euler (GetComponent<Rigidbody> ().velocity.magnitude * tilt, 0.0f, 0.0f);

Im trying to make my plane tilt as it turns. I tried adding your line of code above and that didnt make the plane tilt at all.
It stopped turning as well with that line of code.
Not sure what would make my plane tilt on the x axis as the user hits the right or left keys.

Im trying to mimic this tutorial.
https://unity3d.com/earn/tutorials/projects/space-shooter/moving-the-player

Here’s a simple example:

using UnityEngine;
using System.Collections;
 
public class NewBehaviourScript : MonoBehaviour
{
    public float speed;
 
    float xRot = 0;
    float zRot = 0;
 
    void Update ()
    {
        if (Input.GetKey ("up")) {
            GetComponent<Rigidbody> ().AddForce (Vector3.forward * (Time.deltaTime * speed));
            xRot++;
        }
        if (Input.GetKey ("down")) {
            GetComponent<Rigidbody> ().AddForce (-Vector3.forward * (Time.deltaTime * speed));
            xRot--;
        }
        if (Input.GetKey ("left")) {
            GetComponent<Rigidbody> ().AddForce (-Vector3.right * (Time.deltaTime * speed));
            zRot++;
        }
        if (Input.GetKey ("right")) {
            GetComponent<Rigidbody> ().AddForce (Vector3.right * (Time.deltaTime * speed));
            zRot--;
        }
 
        transform.rotation = Quaternion.Euler (GetComponent<Rigidbody> ().velocity.magnitude * xRot, 0.0f, GetComponent<Rigidbody> ().velocity.magnitude * zRot);
    }
}

Thanks that helps!