I am new in Unity and trying to make a 2d simple car game. I got 4 mobile ui buttons that makes car accelerate, stop, move left, move right. I am using event triggers for every button to transmit the command to the car. PointerDown and PointerUp events correspond following functions: (the exception is every button's PointerUp event goes to MobileMoveStop)
public void MobileMoveLeft()
{
carController.MobileMoveLeft();
}
public void MobileMoveRight()
{
carController.MobileMoveRight();
}
public void MobileMoveForward()
{
carController.MobileMoveForward();
}
public void MobileMoveBackward()
{
carController.MobileMoveBackward();
}
public void MobileMoveStop()
{
carController.MobileMoveStop();
}
And carController class has following codes to operate:
public void FixedUpdate(){
if(leftPressed){
//operations
}
if(rightPressed){
//operations
}
.
.
.
}
public void MobileMoveLeft()
{
leftPressed = true;
}
public void MobileMoveRight()
{
rightPressed = true;
}
public void MobileMoveForward()
{
upPressed = true;
}
public void MobileMoveBackward()
{
downPressed = true;
}
public void MobileMoveStop()
{
rightPressed = false;
leftPressed = false;
upPressed = false;
downPressed = false;
}
So far so good but here is the problem: When i test the game on my phone, the buttons dont work at the same time. I can not accelerate the car while steering left or right. Am i missing something important about event triggers?