- Home /
 
               Question by 
               Jan_Julius · Oct 20, 2014 at 12:04 PM · 
                lerp  
              
 
              Lerp doesn't work after using a lerp?
WHen I run this code when my level is 0 it lerps the rotation of the object and gets it to 0,180,0,0 but when I do it again when it reaches level 2 it doesn't change anything? not while it's lerping on level 0 and neither when it's done lerping?
here is the code:
 public void MoveCamera(int level){
     switch(level){
             case 0:
                 camera.orthographicSize = Mathf.Lerp(camera.orthographicSize, 10, 1*Time.deltaTime);
                 transform.rotation = Quaternion.Lerp (transform.rotation, new Quaternion(0, 180, 0, 0), Time.deltaTime * 0.003f);
         
                 break;
             case 2:
                 camera.orthographicSize = Mathf.Lerp(camera.orthographicSize, 8, 1*Time.deltaTime);
                 transform.position = Vector3.Lerp (transform.position, new Vector3(0, -30, -14), 1*Time.deltaTime);
                 transform.rotation = Quaternion.Lerp (transform.rotation, new Quaternion(0, 0, 0, 0), Time.deltaTime * 0.01f);
                 break;
             case 3:
                 camera.orthographicSize = 11;
                 transform.position = Vector3.Lerp (transform.position, new Vector3(0, -27.5f, -19), 1*Time.deltaTime);
                 break;
             }
 }
THanks,
               Comment
              
 
               
              I think you might have problems writing something like "new Quaternion(0, 180, 0, 0)" because quaternions are not euler angles, ins$$anonymous$$d they are very complex numbers that you have to calculate before you can use them.
I don't know; oddly enough it seems to work quite smoothly on the first one but then not useable on the second.
 
               Best Answer 
              
 
              Answer by _Yash_ · Oct 20, 2014 at 12:40 PM
Try replacing "new Quaternion(x, y, z, w)" with "Quaternion.Euler(x,y,z)".
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                