Hello,
I have created two buttons using Quad, one for acceleration & other for rotation. Both are working properly , if i press one after another. But if i press both the buttons at a same time , they are not working, only one of them is working, which is pressed first.
For it, i have used OnMouseDown & OnMouseUp to maintain state,I have used same code for both buttons.
The code is as follows:
// Update is called once per frame
void Update ()
{
if (isPressed && isStarted)
{
if (canContinueIncrease)
mySpeed = mySpeed + 0.05f;
if (mySpeed >= 1f)
{
mySpeed = 1f;
canContinueIncrease = false;
}
// print("mySpeed:"+mySpeed);
}
else if (!isPressed && isStarted)
{
if (canContinueDecrease)
mySpeed = mySpeed - 0.05f;
if (mySpeed <= 0f && canContinueDecrease)
{
mySpeed = 0f;
canContinueDecrease = false;
}
// print("mySpeed:"+mySpeed);
}
}
void OnMouseDown ()
{
mySpeed = 0f;
isPressed = true;
isStarted = true;
canContinueIncrease= true;
// print("Started Up mySpeed");
}
void OnMouseUp ()
{
isPressed = false;
canContinueDecrease = true;
}.
So Please help me at where i am doing wrong.
Thanks in advance.