- Home /
 
 
               Question by 
               GANONdork123 · Jan 16, 2017 at 01:40 PM · 
                rotationquaternionraycasthitnormals  
              
 
              Rotate Player to Match Surface Normal While Still Maintaining Y Rotation
So I am using this bit of code to rotate my player to match the normal of the floor underneath him:
 RaycastHit hit;
         if (Physics.Raycast(transform.position, -transform.up, out hit, 1f)){
 
             Vector3 rotation = Vector3.Slerp (hit.normal, hit.normal, Time.deltaTime * 10f);
             point.transform.up = rotation;
 
             transform.rotation = Quaternion.Slerp (transform.rotation, point.transform.rotation, Time.deltaTime * 5f);
         }
 
               the problem is that my player can no longer rotate on the Y Axis, and even if I manage to get them to do so, the player is no longer aligned with the surface normal.
               Comment
              
 
               
              Your answer