Check if object is on screen

This has probably been asked 1.23 * 10^19 times, but I can’t seem to find an answer anywhere.

Making a GUI for my game, and lots of it revolves around have a target crosshair on ingame 3d objects. So I grab the object’s position and do WorldToScreenPoint.

The problem is it sometimes shows up on the screen regardless of whether the object is in view or not. How can I tell whether an object is within the camera’s field of view?

Thanks for any help!

Hi,

Potentially - try using the OnBecameInvisible / OnBecameVisible events on Monobehaviour, setting a flag that the object is visible to the camera.

Hope this works for you!

-BSpline