- Home /
Turn page, smooth rotate
Hi everyone,
I ran again into something I am yet to understand and learn how to achieve : smooth rotate an object from an angle to another. What I want to do in this case is have a button rotate (turn) a page (game object); ideally it should have an array of pages but for now I want to get around this smooth rotate thing. A page should slowly rotate 180 degrees when I press a button, with an exposed speed variable.
Here's what I use and doesn't really do the trick:
 //turn
   
 
 var page1 : GameObject;
 var page2 : GameObject;
 var page3 : GameObject;
 var smooth = 2.0;
 function OnGUI () 
 
 {
 
      if (GUI.Button(Rect(0,0,50,30),"Next"))
             {
             page2.transform.Rotate (0, 0, -180);            
             }
 
       if (GUI.Button(Rect(0,200,50,30),"Previous"))
             {
                 page2.transform.Rotate (0, 0, 180*smooth*Time.deltaTime);            
             }
 
 }
Answer by Meltdown · Aug 02, 2011 at 11:15 AM
Spherical linear interpolation is what you need in this case. Luckily Unity has this built into for you :)
Check out Quaternion.Slerp and its code sample in the documentation.
Your answer
 
 
             Follow this Question
Related Questions
Logical Camera errors... 1 Answer
Rotating Transform Evenly 1 Answer
How to rotate your device and counter rotate camera 0 Answers
Camera rotation around player while following. 6 Answers
Smooth Camera Rotate 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                