Rotating bug solution

I found out by editing the following code, A won’t prioritize over D. If both keys are pressed, nothing happens, and you can easily toggle between both A and D.

if (Input.GetKey(KeyCode.A) && (!Input.GetKey(KeyCode.D)))
        {
            Debug.Log("Turning left");
        }
        if (Input.GetKey(KeyCode.D) && (!Input.GetKey(KeyCode.A)))
        {
            Debug.Log("Turning right");
        }

Basically, it’s saying if A is pressed and D is not pressed, rotate left. If D is pressed and A is not pressed, rotate right. If both are pressed, do nothing.

Privacy & Terms