Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

look rotation only on y axis in unity

        var dir = PlayerMovement.playerTransform.position - transform.position;
        Quaternion LookAtRotation = Quaternion.LookRotation(dir);

        Quaternion LookAtRotationOnly_Y = Quaternion.Euler(transform.rotation.eulerAngles.x, LookAtRotation.eulerAngles.y, transform.rotation.eulerAngles.z);
        transform.rotation = LookAtRotationOnly_Y;
 
PREVIOUS NEXT
Tagged: #rotation #axis #unity
ADD COMMENT
Topic
Name
1+2 =