Я пытался вычислить двойное нажатие на единице для устройств ios, но не смог добиться успеха.К сожалению, игра не распознает двойные щелчки.
Я пробовал разные подходы, такие как pointerdataevent, но мне нравится изучать этот вид двойного щелчка.
void Update ()
{
if (Input.touchCount > 0 && isGrounded== true)
{
for(int i =0; i < Input.touchCount; i++)
{
Touch touch = Input.GetTouch(i);
timeTotal+=1;
Debug.Log(timeTotal);
if (touch.position.x < Screen.width/2 && (timeDelay < 0.5) && (timeTotal == 2))
{
if(pathManager.randomDirection == 0)
{
rb.AddForce(new Vector3(-4, 5, 4), ForceMode.Impulse);
rb.velocity = Vector3.zero;
timeTotal = 0;
timeDelay =0;
}
else if(pathManager.randomDirection == 1)
{
rb.AddForce(new Vector3(-4, 5, 4), ForceMode.Impulse);
rb.velocity = Vector3.zero;
timeTotal = 0;
timeDelay =0;
}
}
}
else if (touch.position.x > Screen.width/2 && (timeDelay > 0.5) && (timeTotal == 1))
{
if(pathManager.randomDirection == 0)
{
rb.AddForce(new Vector3(4f, 5f, 8f), ForceMode.Impulse);
rb.velocity = Vector3.zero;
timeTotal = 0;
timeDelay =0;
}
else if(pathManager.randomDirection == 1)
{
rb.AddForce(new Vector3(4f, 5f, 8f), ForceMode.Impulse);
rb.velocity = Vector3.zero;
timeTotal = 0;
timeDelay =0;
}
}