I need an object to to rotate over time. Here is my code that rotates the object.
using UnityEngine;
using System.Collections;
public class CrouchTesting : MonoBehaviour
{
//Variables Start
//Public Variables
public float xRotation = 90.0f;
public float xRotation1 = 0.0f;
public float RotationSpeed = 2.0f;
//Private Variables
//Variables End
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(Input.GetKey(KeyCode.LeftShift))
{
transform.eulerAngles = new Vector3(xRotation, transform.eulerAngles.y, transform.eulerAngles.z);
}
if(Input.GetKey(KeyCode.Z))
{
transform.eulerAngles = new Vector3(xRotation1, transform.eulerAngles.y, transform.eulerAngles.z);
}
}
}
This is when I get stuck.The script works fine like this but it rotates straight away to the angle. I tried to use the rotation speed like this “transform.eulerAngles = new Vector3(xRotation, transform.eulerAngles.y, transform.eulerAngles.z) * RotationSpeed * Time.Deltatime;” But that Is not working. I googled it and nothing cam up.
I do not need a code but examples would be nice.
I think that it is a newbie mistake but I dont know how to do it.
If anyone could help me it would be greatly appreciated.
Thanks in advanced
Infinite Gamer