- Home /
Question by
cgeopapa · Nov 18, 2014 at 07:34 PM ·
cameraquaternionmouselookquaternions
Quaternion.Slerp not smooth!
Man, I hate those Quaternions... they always have a problem waiting for you!
Anyway, I have a pilot at a chopper, so I want when the player presses C the camera to use the MouseLook script and look around, and when he is not pressing it to smoothly go back to its starting position. So I wrote this:
var cockpit = true;
var third: GameObject;
var first: GameObject;
var heli: GameObject;
var look: Transform;
private var lookAt: Quaternion = new Quaternion(0, 0, 0, 0);
function Update(){
if(cockpit == true && Input.GetKey(KeyCode.V)){
first.GetComponent(MouseLook).enabled = true;
heli.GetComponent(Move).enabled=false;
}
else{
first.GetComponent(MouseLook).enabled = false;
heli.GetComponent(Move).enabled=true;
look.rotation = Quaternion.Slerp(transform.rotation, lookAt, 0.1 * Time.deltaTime);
}
}
It works fine until it comes to move the camera back to its starting position witch moves it instantly, so the problem is at that dam Quaternion! Help, pleaze!!!! :)
Comment