I am developing a platformer with 2D gameplay and have a camera script set up that nicely follows the player character. Now, I would like to constrain this following movement:
If the player falls into a hole, the camera shouldn't follow, but let him fall out of the field of view.
If the level has an upper bound (like in tunnel), the amount visible above should be constrained, too.
For this, I need some kind of way to limit the camera's field of view to specific lower/upper bounds, ideally in a way that is independent of the camera's distance to the player (independent as in "allows for the camera distance to change and still work"). Is there a way to accomplish this with Unity?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
No one has followed this question yet.
How to make camera position relative to a specific target.
[SOLVED]Why is this scripts output so choppy/glitchy?
Adjust the height of the camera according to z-value
Phantom camera translation when trying to set screen size
How do I set up a GUI around multiple cameras?