- Home /
Using the arrow keys?
Hello. I am making a 2D shooter with an over head camera (the game is along the ZX plane if that helps). I want to make it so that when the arrow keys (or IJKL) are held down, a projectile will move outward from the player object in the direction that was pressed, how would I do that? Also, I am using WASD for another type of control (character movement), so how would I need to change around the input settings? Thank you
Answer by peacemaker · Nov 15, 2010 at 08:52 AM
You can change the input options in the Input menu from WASD to the arrow keys.
In your script you can also listen for specific keys, like so:
Update()
{
if ( Input.GetKey(KeyCode.UpArrow) )
//move up
if ( Input.GetKey(KeyCode.DownArrow) )
//move down
if ( Input.GetKey(KeyCode.RightArrow) )
//move right
if ( Input.GetKey(KeyCode.LeftArrow) )
//move left
}
Answer by AlanMattano · May 15, 2014 at 04:13 PM
How would I need to change around the input settings?
To add the arrow key in negative or positive Button, in the InputManager type:
"up"
"down"
"left"
"right"
InputManager is in: Edit -> ProjectSettings -> Input
"up" is equal to KeyCode.UpArrow (script) etc