How to move character with UI buttons?
Hi guys, i'm having problems with UI buttons, I've already created the character and he is walking, but well, only in PC version. i'm doing something like an update and i cant imagine a scripting that could make my character walks with the animation i've did. i had done the buttons and i've read in internet that i should use event trigger like pointer down and pointer up and i know how to use, however dont know a method that i could use with it, and then i'm here asking for help. sorry for the bad english guys );
look here the code i'm using to movement with only the keyboard.
void Move()
{
movx = Input.GetAxis("Horizontal");
animator.SetFloat("Movimento", Mathf.Abs(movx));
if (movx > 0 && !olhandoDireita ) // se o movimento de x for pra direita > 0 e ele nao tiver olhando pra direita, fazer o Flip
{ Flip(); }
else if (movx < 0 && olhandoDireita ) // se o movimento de x for pra esquerda < 0 e ele tiver olhando pra direita, fazer o Flip
{ Flip(); }
playerRb.velocity = new Vector2 (movx * velocidade, playerRb.velocity.y);
}
i looked at internet a code like this, however the animation did not work :
private int auxhorizontal;
public float speed
void Update()
{
if(auxhorizontal !=0){
transform.Translate(0,0,speed*Time.deltaTime.auxhorizontal);
}
public void movehorizontal (int direction)
{
auxhorizontal = direcao;
}
}
would like some kind of help please ):
Your answer
Follow this Question
Related Questions
Mobile Left and right move input for the player in 2D (Top Down) 0 Answers
Moveable Button that resets when click is over 0 Answers
How do I assign a velocity to an object on only 1 axis? 1 Answer
Script to animation and movement of 2d player 1 Answer
UI Text Editing Problem, What's Wrong? Need Anybody to Assist 1 Answer