- Home /
Question by
alexanderameye · May 18, 2014 at 09:15 AM ·
c#monodeveloplerpslerp
Problem with camera transitions (slerp)
I have this code before Start()
public Camera ThirdPerson;
public Camera FirstPerson;
//Sets the current camerastate to true (default is Third-Person)
private bool Camerastate = true;
And this code in Update()
//Sets camerastate to the Third-Person when true, and First-Person when false
if(Camerastate == true)
{
ThirdPerson.enabled = true;
FirstPerson.enabled = false;
transform.position = Vector3.Slerp(ThirdPerson.transform.position, ThirdPerson.transform.position, Time.deltaTime * Smooth);
transform.rotation = Quaternion.Slerp(ThirdPerson.transform.rotation, ThirdPerson.transform.rotation, Time.deltaTime * Smooth);
}
else
{
ThirdPerson.enabled = false;
FirstPerson.enabled = true;
transform.position = Vector3.Slerp(FirstPerson.transform.position, FirstPerson.transform.position, Time.deltaTime * Smooth);
transform.rotation = Quaternion.Slerp(FirstPerson.transform.rotation, FirstPerson.transform.rotation, Time.deltaTime * Smooth);
}
//Sets the Camerastate to the opposite of the current Camerastate
if(Input.GetKeyDown(KeyCode.Tab))
{
Camerastate = !Camerastate;
}
////////////////////////////////////////////////////////////////////////////////////////////
If I run this it goes very smooth from First-Person to Third-Person, but not smooth from Third-Person back to First-Person. How can I fix this? Thanl you very much!!
Comment
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Why do Two Instances of MonoDevelop Open when I double-click a CS file in Inspector? 0 Answers
Problem with Camera Transition (First-person to third-person, with Slerp) 1 Answer
Problem with getkey/getkeydown 1 Answer
Rotation with RotateAround 2 Answers