#Use ``eulerAngles`` whenever you need to

1 messages · Page 1 of 1 (latest)

deep bear
#

I tried it. the up-limit work well, but the down limit doesn't work

 void Rotation()
    {
        float angleZ = transform.eulerAngles.z;

        if (verticalInput == 1 && angleZ <= 34f)
        {
            transform.rotation *= anguloW;
        }

        if( verticalInput == -1 && angleZ >= -34f)
        {
            transform.rotation *= anguloS;
        }
dense snow
#

It sets the angle to be closest angle from 0, so it is in the -180 to 180 range

deep bear
#

thanks

#

one more thing when I establish the "AnguloW " and the "AngulosS", the inspector writes it betwen 0 to 360 angles, is there a better way to write it?

dense snow
#

Because Unity uses the Quaternion data type to store rotations

#

But Euler angles (Vector3) can't represent that fully

deep bear
#

the problem is that I write (0,0, -10f); and it rotates counterclockwise

#

When I need it to rotate clockwise

dense snow
#

Yeah just replace -10 with 10 and so on 😁

#

@deep bear

deep bear
#

I am trying it 😅

#
 public Quaternion anguloW = Quaternion.Euler(0f, 0f, -10f);
    public Quaternion anguloS = Quaternion.Euler(0f, 0f, 10f);

the W rotates faster than the S rotation

#

@dense snow

deep bear
#

?