I'm trying to make an object's transform.up to a normal of the raycastHit point. I tried using this line of code:
transform.up = Vector3.Lerp(transform.up, normal, 1 * Time.deltaTime);
This works well but locks the y-axis rotation as a result the object can't rotate and just keeps going forward. I tried using Quaternion.LookRotation. But I couldn't make it affect the object's rotation. Here is what I tried:
bodyRotation = Quaternion.LookRotation(transform.forward, normal); transform.rotation = Quaternion.Slerp(transform.rotation, bodyRotation, 100 * Time.deltaTime);
How can I set the transform.up without locking the y-axis?