- Home /
Question by
santyarellano039 · Jan 23, 2017 at 02:35 PM ·
2d game
Unity 2d - stop sprite from leaving the screen
I'm making an Android 2D up to down game and want to avoid the object from leaving the screen. The problem is that the screen size changes between phones, so if I try to use colliders at the limits of the screen, if the resolution changes, the colliders will end either inside the screen or outside. Is there an easy way to achieve what I want?
Comment
Orthographic or perspective camera?
You can calculate where the camera bounds are in world units and place colliders there. It's easier with orthographic camera but possible with either one. Here's an older question about the same thing
It's orthographic... how do I calculate them??
This link to another Unity Question should be able to assist you with $$anonymous$$athf.Clamp if you have any issues.