How I can calculate corners of player's screen in 3D?

Hi guys. I have gotten a need to get 3D position of screen corners, which will include FoV.
I know, that there’s some Camera methods exist, like Camera:ViewportPointToRay(), but they don’t fit my needs, because they account for device safe areas. I don’t need to account for them, because, well, they are rendered too, and so they are valid for me placing something here.

1 Like

To get 3D positions of screen corners:

  1. Use Camera.ViewportToWorldPoint() with viewport coordinates (0,0), (1,0), (1,1), and (0,1)
  2. These represent bottom-left, bottom-right, top-right, and top-left corners
  3. Include a z-distance value to determine how far from camera the points should be
  4. This approach ignores safe areas and uses the entire screen

The ViewportToWorldPoint() method transforms normalized viewport coordinates (0-1 range) directly to world space positions, which is what you need for placing objects at screen corners.​​​​​​​​​​​​​​​​

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.