Perspective camera
I know there are some ways to judge whether an GameObject is in the field of view of the perspective camera.
There is a rectangular area on the screen, how to judge whether the GameObject is in this rectangular area
To know if a point is in the field of view of the camera, you check if Camera.WorldToViewportPoint for that point returns a value between 0 and 1 for both the x- and y-axes, and the z-value is greater than 0:
For a GameObject, that completely depends on what visual components it has. It could have a visible child gameobject that’s offset from the center, so it depends. A surefire way would be to make some bounds that encapsulate all the mesh renderer’s bounds and check if all of the corners on those bounds are inside the viewport, as above. I wouldn’t do that unless the simple check for the gameobject’s position isn’t cutting it.[/Quote]
1 Like
Very useful to me , thank you