我搜索了不同的解决方案,以使对象在VR中离开特定摄像机视口时消失。使对象在VR中离开特定摄像机视口时消失
最后我用用GeometryUtility以下解决方法:
//Create camera planes
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
//Check if object renderer is in camera view
if (!GeometryUtility.TestPlanesAABB(planes, GetComponent<Renderer>().bounds))
{
//Condition waiting for 2nd object to spawn (To avoid object 1 doesn't disappear instantly)
if (objectCondition.activeSelf)
{
//Deactivate object
gameObject.SetActive(false);
}
}
然而,这导致对象消失之前,它是从视口(约中途退出,而不是一路)。我是否实施了这个错误,还是仅仅是一个VR问题?
您是否设置了正确的界限?该脚本在您当前的gameobject中被禁用?这个gameobject有一个对撞机? – joreldraw