- Home /
Why is part of object outside camera frustum visible?
Hi,
I'm making a 2D game with an Orthographic camera, so my view frustum is a cuboid. I have a really long cube GameObject (moving platform), which is much wider than the view frustum, traveling in the +x direction across the view frustum from the left to the right. I expect that only the part of the GameObject which is inside the camera's view frustum will ever be visible. The frustum has a background applied on the far plane.
My Game window is sized to fit the camera's view frustum exactly, so things look alright when I preview the game in the Game window. I ran my game on an actual device (phone) in landscape mode where the screen is a lot wider than the view frustum's width, which causes blue bands on either side of my view frustum. But annoyingly, parts of the moving platform GameObject that are outside the frustum are also visible.
I don't understand what I'm doing wrong. Am wrong in expecting that the part of the object that's outside of the view frustum will not be visible? Or did my view frustum change in width when the game was run on the device because the device screen was a lot wider?
Thanks in advance for your help!
Answer by GameVortex · Nov 18, 2013 at 10:55 AM
An orthographic camera will use the same aspect ratio as the current resolution of the device or screen or window it is displayed on uses. So as you found out, on a wider mobile phone it will have a larger width than that on your developer machines screen, and therefore your object is visible "outside" of your original frustum.
The way around this issue is to have your game support the widest possible aspect ratio available on the platform(s) you intend to deploy your game on. In your case that would be to extend the background more in width to fill up the entire screen and make the game okay with the object being visible for longer.
Another option would be to put a pair of black planes on either side of your cameras original view frustum so nothing will be visible there if the aspect would change on another device.
Thanks, the "black plane on either side" approach makes more sense for my game.
Your answer
Follow this Question
Related Questions
Dynamic shadows in orthographic camera. 2 Answers
How do I stop objects from ghosting on screen? 1 Answer
Set camera to specify x,y in pixels? 2d 0 Answers
Questions about Unity 2D camera setup 1 Answer
Calculating 2D camera bounds 8 Answers