- Home /
Question by
ismailounjif · Mar 29, 2018 at 11:07 AM ·
androiduibuttonmovemobile devices
move player with button problem
when i use this function with button , player change his position one time i use this function with event trigger.
public void right(){
this.transform.localPosition += transform.right * oxspeed * Time.deltaTime;
}
Comment
Answer by RyanAtEvno · Mar 29, 2018 at 06:48 PM
Why cant you just use
if ( Input.GetKey(KeyCode.RightArrow) )
//move right
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
}