当我把相机的属性,设置成如下图所示时,射线的碰撞到的点和我用鼠标点击的点有偏差 如果设置成 如下图所示时,就没有偏差了。 我想知道,如果相机的FOV角度小,会导致发射出的射线的碰撞的点和鼠标的点击的点有偏差吗?为什么会这样?还是说我的代码有问题? Code (CSharp): public RaycastHit[] ScreenPointToRay(UdpDataReult udpDataReult) { ray = m_Camera.ScreenPointToRay(udpDataReult.src_point); hitCount = Physics.RaycastNonAlloc(ray, hit, Mathf.Infinity, layerMask); if (hitCount > 0) { hitInfo = new RaycastHit[3]; for (int i = 0; i < hit.Length; i++) { if (hit[i].transform == null) continue; if (hit[i].transform.gameObject.layer.Equals(llayerMask_Target_Int)) { if (hitInfo[0].collider == null) hitInfo[0] = hit[i]; if (hitInfo[0].distance > hit[i].distance) hitInfo[0] = hit[i]; } else if (hit[i].transform.gameObject.layer.Equals(layerMask_Default_Int)) { if (hitInfo[1].collider == null) hitInfo[1] = hit[i]; if (hitInfo[1].distance > hit[i].distance) hitInfo[1] = hit[i]; } else if (hit[i].transform.gameObject.layer.Equals(layerMaskSuimono_Water_Int)) { if (hitInfo[2].collider == null) hitInfo[2] = hit[i]; if (hitInfo[2].distance > hit[i].distance) hitInfo[2] = hit[i]; } if (hitInfo[0].collider != null && hitInfo[1].collider != null) break; } } else hitInfo = new RaycastHit[2]; return hitInfo; }
"When I set the properties of the camera as shown in the figure below, there is a deviation between the point where the ray hits and the point I clicked with the mouse." "If it is set as shown in the figure below, there is no deviation." "I want to know, if the FOV angle of the camera is small, will the collision point of the emitted ray be deviated from the point of the mouse click? Why is this happening? Or is there something wrong with my code?" These are the three paragraphs in the forum's native language. Can we see the mouse input or screen input coordinates?