Hi !
I’m trying to make my camera rotate when you press a button (end of turn button).
I tryed to use Quaternion.Lerp. It works but only once ! Can someone explain me why ?
I mean, the rotation work the second time. But it directly go from 0 to 180 in 1 frame…
Thanks a lot !
using UnityEngine;
using System.Collections;
public class Camera : MonoBehaviour {
public GameController gc;
Quaternion from;
Quaternion to;
void Start () {
from = Quaternion.Euler(0,0,0);
to = Quaternion.Euler(0,0,180);
}
void Update () {
if (gc.player_turn == 1) {
transform.rotation = Quaternion.Lerp (from, to, Time.time * 0.4f);
} else if (gc.player_turn == 2) {
transform.rotation = Quaternion.Lerp (to, from, Time.time * 0.4f);
}
}
}