Alternative code to disallow pressing A and D keys together

For me this worked better than the version on the course video:

if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D)) {
print(“You can not go left and right at the same time.”);
} else {
if (Input.GetKey(KeyCode.A)) {
print(“Rotating left”);
}
if (Input.GetKey(KeyCode.D)) {
print(“Rotating right”);
}
}

Privacy & Terms