我一直在尝试将ios设备的双击统一化,但未能成功。 不幸的是,游戏无法识别双击。
我尝试了类似指针数据事件的不同方法,但是我也喜欢学习这种双击。
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;
}
}