Question about positive and negative imput values.

Hello !

So i was reading the documentation a while, and finnaly got this to work verry nicely !
But now im seriously bugged about something.

This part of the code makes the “ship” rotate to the left smoothly. This works perfectly.

//if you press A key ship will rotate Z +  axis
     if (Input.GetKey (KeyCode.A))
        { 
            playerShip = Quaternion.Euler (0, 0, tiltAroundZ);

            //Dampens twoards the rotation
            transform.rotation = Quaternion.Slerp(transform.rotation, playerShip, Time.deltaTime * smooth);

            print ("Horizontal Positive key A was Pressed");

        }

What im wondering is why the code makes it rotate to the right if i change the keycode to D key. With the same values and exactly the same code as above ?

You have it there! First you have
//if you press A key ship will rotate Z + axis and than //if you press A key ship will rotate Z - axis. So in this case, raw A value returns 1 and raw D input value -1 so it rotates to the opposite direction! And the tilt value for horizontal rotation is negative so you will get positive tilt value for D and negative for A if I am sure. Go to project settings-input in unity and check the positive and negative value. AND you were wondering why does the ship tilt to right when you change the key code to D, well that’s because you use the keycody only in the if statement and use axis in the tilt variable.

I am writing the code atm.

Owh ! then i understand, i was a bit baffled that it returned - value and + value by its self. i thought i had to write a new if statement for each + and minus value.
thanks for clearing that up !

Yeah the tilting i knew already why since that was the code i was writing, it was basicaly why did it tilt without me writing a positive value for the D.

You can copypaste the code and drag it onto a prefab with a player tag and it will auto work.

Thanks for clearing the part about negative and positive values given by the keycode.
You were right about the positive and negative values given by the keys. it was autosetup. i never knew that so thanks again, i learned something new trough this.