Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SepM · Aug 28, 2015 at 08:19 PM · cameramultiplayerrendererisvisible

renderer.is(Completely)Visible?

I'm trying to make a camera that follows two players which zooms in and out. It zooms in when both characters are visible and zooms out when one or more aren't visible. I used renderer.isVisible to approach this and it works well; but it's not entirely what I want. A character that is completely off of the screen except for a single pixel will register as "visible." Is there a way that I can only call a character visible if they are entirely on the screen?

Please, no links to the documentary or previously asked questions. I don't even necessarily need code (although that would be nice!) but just an idea or a good way to approach this. Thanks in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dave-Carlile · Aug 28, 2015 at 08:24 PM

A potential way to do this would be to use Camera.WorldToScreenPoint on several vertices that bound your object (you can probably calculate these vertices using renderer.bounds). If all of the vertices are within the screen bounds then the object is entirely on the screen.

There is also GeometryUtility.TestPlanesAABB which may eliminate some of that work. You can pass Renderer.bounds along with the frustum planes calculated by GeometryUtility.CalculateFrustumPlanes. But the documentation isn't entirely clear if it returns true only if the bounds are entirely within/touching the planes, or if it would return true if it's partially within, so you'd need to test that.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Baste · Aug 28, 2015 at 10:19 PM 0
Share

I believe renderer.isVisible will give you exactly the same results as GeometryUtility.TestPlanesAABB with Renderer.bounds. The only big difference is that isVisible will check all active cameras, while GeometryUtility lets you pick.

Haven't tested it though, but I'd be supprised if that wasn't the case.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# Renderer.IsVisible counts when editor camera sees object 0 Answers

How can I show split screen or multiple camera views at the same time? 1 Answer

Hiding model for local player 1 Answer

GameObject invisible at certain camera angles 0 Answers

Is there a shader in Unity that prevents transparent parts from overlapping? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges