Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.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
Unity3d 为什么刚体速度不同导致分辨率不同?_Unity3d - Fatal编程技术网

Unity3d 为什么刚体速度不同导致分辨率不同?

Unity3d 为什么刚体速度不同导致分辨率不同?,unity3d,Unity3d,我正在unity中使用此comamnd移动objectan UI按钮: Player.GetComponent<Rigidbody2D>().velocity = new Vector2(x,x); 因为Screen.Width返回的结果是像素。不同的设备有不同的像素分辨率;这意味着在每个分辨率中,我都从0移动到宽度/2。不是吗?不是。对象将在三维世界空间中移动。与您的屏幕分辨率非常不同。但是如果你想保持屏幕的中间位置移动,请使用screentoworldpoint,而不是刚体强制

我正在unity中使用此comamnd移动objectan UI按钮:

Player.GetComponent<Rigidbody2D>().velocity = new Vector2(x,x);

因为Screen.Width返回的结果是像素。不同的设备有不同的像素分辨率;这意味着在每个分辨率中,我都从0移动到宽度/2。不是吗?不是。对象将在三维世界空间中移动。与您的屏幕分辨率非常不同。但是如果你想保持屏幕的中间位置移动,请使用screentoworldpoint,而不是刚体强制。主要目标是从左向右跳转。但是跳转在所有设备和所有分辨率中都应该是相同的。使用screentoworldpoint是个好主意吗?这可能会有所帮助
x = Screen.Width/2;