Its in the question, Im new jsut started today if any one can help
Here is a solution to your updated question:
using UnityEngine;
using System.Collections;
public class Bug20 : MonoBehaviour {
Quaternion qTo;
float speed = 90.0f;
void Start() {
qTo = transform.rotation;
}
void Update () {
if (Input.GetKeyDown(KeyCode.A))
qTo = Quaternion.LookRotation(Vector3.left);
else if (Input.GetKeyDown(KeyCode.D))
qTo = Quaternion.LookRotation(Vector3.right);
else if (Input.GetKeyDown(KeyCode.W))
qTo = Quaternion.LookRotation(Vector3.forward);
else if (Input.GetKeyDown(KeyCode.S))
qTo = Quaternion.LookRotation(Vector3.back);
transform.rotation = Quaternion.RotateTowards(transform.rotation, qTo, Time.deltaTime * speed);
}
}
‘speed’ is degrees per second. If you want a more eased movement, replace ‘RotateTowards’ with ‘Slerp’ and reduce the speed variable (perhaps to around 5).
this.transform.Rotate(0,20,0);//rotate 20 units every second, put this line in the FixedUpdate(){}
“this” refers to a script that is attached to some gameObject (Or has to be attached at least).
We want to access the Transform component from the current Script component, so we use a default variable “transform”.
transform allows us to use different functions to alter itself, Rotate() is one of them.