it’s my code when I run my game in mobile it only works with keys
private float MoveSpeed;
Rigidbody2D rig;
public void MoveToLeftAndRight(){
if (Input.GetAxisRaw ("Horizontal") !=0) {
rig.velocity = new Vector2 (MoveSpeed * (Input.GetAxisRaw ("Horizontal")), rig.velocity.y);
transform.localScale = new Vector3 (1 * (Input.GetAxisRaw ("Horizontal")), 1, 1);
}
else if(rig.velocity.y==0) {
rig.velocity = new Vector2 (0,rig.velocity.y);
}
}
but I want to create a button and when you touch the button, character moves to right;
can anyone show me a very simple example?