public GameObject[] targets = new GameObject[4];
private int preTarget;
public float rotateSpeed = 20;
void Update () {
RotateToTarget ();
}
public void TurnLeft() {
preTarget += 1;
if (preTarget > 3) {
preTarget = 0;
}
}
public void TurnRight() {
preTarget -= 1;
if (preTarget < 0) {
preTarget = 3;
}
}
void RotateToTarget() {
Quaternion rotation = Quaternion.LookRotation (targets[preTarget].transform.position - this.transform.position);
this.transform.rotation = Quaternion.Slerp (this.transform.rotation, rotation, Time.deltaTime * rotateSpeed);
}
}