Hi.
I’m making a 2D game and I’m trying to port this to Android. I’m using script below to touch left and right side of screen to move player (with OnPointerUp and Down). Unfortunately sometimes game not recognizing I’ve touched button. It’s totally random. Can someone tell me, what’s going on? (sorry for my English btw)
Best Regards.
Script:
public bool moveLeft;
public bool moveRight;
public float buttonsSpeed;
public void Buttons()
{
if (moveLeft && !moveRight)
GetComponent<Rigidbody2D> ().transform.Translate (Vector3.left * buttonsSpeed);
if (moveRight && !moveLeft)
GetComponent<Rigidbody2D> ().transform.Translate (Vector3.right * buttonsSpeed);
}
public void MoveMeLeft()
{
moveLeft = true;
}
public void StopMeLeft()
{
moveLeft = false;
}
public void MoveMeRight()
{
moveRight = true;
}
public void StopMeRight()
{
moveRight = false;
}