Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.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
Android 移动设备上的统一夹具问题_Android_Ios_Unity3d_Game Physics_Physics Engine - Fatal编程技术网

Android 移动设备上的统一夹具问题

Android 移动设备上的统一夹具问题,android,ios,unity3d,game-physics,physics-engine,Android,Ios,Unity3d,Game Physics,Physics Engine,我使用以下代码: void Update () { if (SystemInfo.deviceType == DeviceType.Desktop) { float xMovement = Input.GetAxis("Horizontal"); this.rb.velocity = new Vector2(xMovement, 0) * this.speed; } else if (SystemInfo.deviceType

我使用以下代码:

    void Update () {
    if (SystemInfo.deviceType == DeviceType.Desktop) 
    {
        float xMovement = Input.GetAxis("Horizontal");
        this.rb.velocity = new Vector2(xMovement, 0) * this.speed;


    } else if (SystemInfo.deviceType == DeviceType.Handheld) 
    {
        if (Input.touchCount > 0) 
        {
            Touch touch = Input.GetTouch(0);
            if (touch.position.x > this.westTouchBound && touch.position.x < this.eastTouchBound) 
            {

            } else 
            {
                this.speed = this.ballRigidBody.velocity.magnitude * 2.0f;

                Vector3 location = this.gameCamera.ScreenToWorldPoint(touch.position);

                Vector3 delta = location - this.transform.position;
                Vector2 course = new Vector2(delta.x, 0.0f);
                course.Normalize();
                this.rb.velocity = course * speed;

            }

        } else 
        {
            this.rb.velocity = new Vector2(0, 0);
        }

    }
    float eastMax = this.gameController.screenWidth / 2.0f - this.gameController.wallThickness - this.gameController.barWidth / 2.0f;
    float westMax = -eastMax;

    float actualX = Mathf.Clamp(this.transform.position.x, westMax, eastMax);
    this.transform.position = new Vector3(actualX, this.transform.position.y, this.transform.position.z);

}

在mac上,它工作得很好,但在iOS或安卓系统上,它只是在边界上反弹,然后又反弹回来,看起来很可怕。我研究了日志,似乎问题出在物理上,看起来PC对日志的处理方式与移动设备不同。我尝试了很多东西,将代码移动到FixeUpdate、LateUpdate,尝试更改控件,甚至尝试分配刚体位置,但仍然不起作用。

我以前遇到过类似的情况

把这个换掉

float actualX = Mathf.Clamp(this.transform.position.x, westMax, eastMax);
用这个

if(actualX < westMax)
{
    actualX = westMax;
}
else if(actualX > eastMax)
{
    actualX = eastMax;
}

看起来夹钳坏了或是什么东西

这不起作用。我认为物理学中存在一个问题。