I just started coding yesterday however, I have ran into this issue and however much I google I can't seem to find the right answer.
if(Input.GetKey(KeyCode.D)) || if(Input.GetKey(KeyCode.RightArrow))
{
target_right = new Vector2(transform.position.x + right_increment, transform.position.y);
transform.position = target_right;
}
I have read online that || in plain English means or. I want both button D and the right arrow button to execute the code. How do I do this?
Your syntax should look like this
if( Input.GetKey(KeyCode.D) ||Input.GetKey(KeyCode.RightArrow))
{
target_right = new Vector2(transform.position.x + right_increment,
transform.position.y);
transform.position = target_right;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With