Answers for "Return object to position"
http://answers.unity.com/questions/276706/return-object-to-position.html
The latest answers for the question "Return object to position"Answer by franktrog
http://answers.unity.com/answers/278129/view.html
Well I figured out my issue. In the first part of the Slerp I was forgetting to identify which object to use for the "from" transform.rotation point. Here is the final code.
if(iFocusB){
camTrigger = 1;
}
if(iFocusRB){
camTrigger = 2;
}
if(iFocusTB){
camTrigger = 3;
}
if(Input.GetMouseButton(0)){
camObj.transform.Rotate(Vector3(Input.GetAxis("Mouse Y"), 0, Input.GetAxis("Mouse X")) * Time.deltaTime * speed);
}
if(camTrigger == 1){//Triggers when iFocusB is pushed
camObj.transform.rotation = Quaternion.Slerp(camObj.transform.rotation, Quaternion.Euler(92,-50,0), Time.deltaTime*smooth);;
if(camObj.transform.rotation == Quaternion.Euler(92,-50,0)) camTrigger = 0;
}else if(camTrigger == 2){//Triggers when iFocusRB is pushed
camObj.transform.rotation = Quaternion.Slerp(camObj.transform.rotation, Quaternion.Euler(90,90,0), Time.deltaTime*smooth);;
if(camObj.transform.rotation == Quaternion.Euler(90,90,0)) camTrigger = 0;
}else if(camTrigger == 3){//Triggers when iFocusTB is pushed
camObj.transform.rotation = Quaternion.Slerp(camObj.transform.rotation, Quaternion.Euler(20,15,92), Time.deltaTime*smooth);;
if(camObj.transform.rotation == Quaternion.Euler(20,15,92)) camTrigger = 0;
}
Thanks for the help everyone!Mon, 02 Jul 2012 22:45:22 GMTfranktrogAnswer by Piflik
http://answers.unity.com/answers/276749/view.html
Not sure if that helps, but I highly doubt you will ever reach Quaternion.identity this way. There are two problems: Gimbal Lock and accuracy. The former is not solvable with a fixed rotation order, the latter could be fixed by rounding...
Anyway, why don't you simply use Quaternion.Slerp?
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.identity, Time.time * speed);Fri, 29 Jun 2012 18:13:18 GMTPiflikAnswer by irrationalistic
http://answers.unity.com/answers/276747/view.html
This should really be in a coroutine with yields or in the object's Update() function. While statements execute until they are completed and don't care about frame-rate.Fri, 29 Jun 2012 18:06:39 GMTirrationalistic