1
I’m trying to rotate an object only on the X and Z axes, keeping the original value on the Y axis, but this way the rotation just doesn’t work, or gets totally misaligned.
RaycastHit hit;
if (Physics.Raycast(transform.position, -Vector3.up, out hit, layerMask))
{
Quaternion rotation = Quaternion.RotateTowards(transform.rotation,
Quaternion.FromToRotation(Vector3.up, hit.normal), 5F);
transform.rotation = Quaternion.Euler(rotation.x, transform.rotation.y, rotation.z);
}