Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 统一触摸位置不工作_C#_Android_Ios_Unity3d - Fatal编程技术网

C# 统一触摸位置不工作

C# 统一触摸位置不工作,c#,android,ios,unity3d,C#,Android,Ios,Unity3d,我的Android/iOS游戏有一些问题。 概念非常简单(纵向模式): 如果你点击屏幕的左侧,它会将球撞向右侧。 如果你点击屏幕的右侧,它会将球撞向左侧 问题是,我在控制器脚本中添加了以下代码: void TouchManagement() { for(int i = 0; i< Input.touchCount; ++i) { Touch touch = Input.GetTouch(i); if(t

我的Android/iOS游戏有一些问题。 概念非常简单(纵向模式): 如果你点击屏幕的左侧,它会将球撞向右侧。 如果你点击屏幕的右侧,它会将球撞向左侧

问题是,我在控制器脚本中添加了以下代码:

void TouchManagement()
    {
        for(int i = 0; i< Input.touchCount; ++i)
        {
            Touch touch = Input.GetTouch(i);
            if(touch.phase == TouchPhase.Began)
            {
                Debug.Log(touch.position);
                if(touch.position.x > Screen.width/2f && timer == 0f)
                {
                    BumpLeft();
                }
                else if (touch.position.x <= Screen.width / 2f && timer == 0f)
                {
                    BumpRight();
                }
                timer = cooldown;
            }
        }
    }
void touch管理()
{
对于(int i=0;iScreen.width/2f&&timer==0f)
{
BumpLeft();
}

else if(touch.position.x)可能计时器不完全为0.0f?比较浮点值与相等值总是很棘手。如果Debug.Log(…)不起作用,请将触摸位置写入屏幕上的UI.Text。请添加指向其他论坛帖子和问题的链接。可能计时器不完全为0.0f?比较浮点值与相等值总是很棘手。如果Debug.Log(…)不工作,请将触摸位置写入UI。屏幕上的文本。请添加指向其他论坛帖子和问题的链接。