Hi! I’m a beginner and I’m making my first game for android. I’ve my character and I’m using 3 buttons to move left, right and jump. I want to hold the button to move but onPointerDown() which I put on the buttons not working as I expected. Here is some code :
moving Left: which I’m triggering with onPointerDown() event on my button
public void movL()
{
ismov = true;
if (ismov)
{
rb.velocity = Vector2.left * 2f;
}
else
{
rb.velocity = Vector2.zero;
}
}
stop moving, which I’m calling at onPointerup()
public void stopmov()
{
ismov = false;
}
What I’m doing wrong?
Or Is there any other method to move while the button is being pressed like any other android game?