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.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
No one has followed this question yet.
How to make camera position relative to a specific target.
What is wrong with my raycast
Player UI freezes when rendering to render texture.
Jumpy object movement and camera movement
Renderer.isVisible always returning false