Here's the method I used with success:
Convert the position of the object into viewport space. If the viewport space is within 0-1 you are in the cameras frustum. This method also allows you to add a margin amount if you want, so that objects turn on when they are almost in view.
Vector3 screenPoint = playerHead.leftCamera.WorldToViewportPoint(targetPoint.position);
bool onScreen = screenPoint.z > 0 && screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1;
No comments:
Post a Comment