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);
}
}
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.