- Home /
 
 
               Question by 
               KacperGorgon · Dec 01, 2020 at 08:50 PM · 
                rotationraycastquaternionlerp  
              
 
              How can I smooth the rotation using quaternion and raycast?
I'm trying to create Arcade Car Controller and my main problem is to rotate car's model smoothly. How can I do this? Here's my code:
 if (Physics.Raycast(ray, out hitInfo, 2.0f, GroundMask))
 {
         kartModel.rotation = Quaternion.FromToRotation(transform.up, hitInfo.normal) * transform.rotation;
 }
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by KacperGorgon · Dec 02, 2020 at 12:00 PM
If somebody interested I solved the problem using Lerp instead:
 if (Physics.Raycast(ray, out hitInfo, 2.0f, GroundMask))
         { 
             kartNormal.up = Vector3.Lerp(kartNormal.up, hitInfo.normal, Time.deltaTime * 8.0f);
             kartNormal.Rotate(0, transform.eulerAngles.y, 0);
         }
 
              Your answer