• 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 /
This question was closed Aug 02, 2014 at 06:34 AM by tanoshimi for the following reason:

Duplicate Question

avatar image
3
Question by squeakywafflez · Aug 01, 2014 at 05:50 AM · cameragameobjectvisible

How do I check if a GameObject is visible by a camera?

I've noticed that this has been posted before, but they all seemed very outdated, so I was wondering if/hoping that it changed. I am looking particularly for JavaScript, so if you give an answer in C# it will be very difficult for me to make sense of it. I was wondering if I could check if a specific GameObject is visible by a specific camera, (if not, any camera) Hoping that the command will return either true/false, or a command that will test when something enters the camera, or leaves the camera.

Thank you!

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

  • Sort: 
avatar image
2
Best Answer

Answer by robertbu · Aug 01, 2014 at 05:56 AM

This answer from 2009 is still valid today.

http://answers.unity3d.com/questions/8003/how-can-i-know-if-a-gameobject-is-seen-by-a-partic.html

Note that all these methods but GeometryUtility.CalculateFrustumPlanes method fire when any camera see an object. With CalculateFrustrumPlanes() and GeometryUtility.TestPlanesAABB() you can test if a specific object is in front of a particular camera.

There is one thing that was true in Unity 3.x days that may not be true today. In the editor, the scene camera counted as 'any camera' and therefore would cause the callbacks to fire or 'isVisible' to be true. I've had some things happen recently that indicate that may not still be true, but I've not run a detailed test.

Comment
Add comment · Show 3 · 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 squeakywafflez · Aug 02, 2014 at 03:15 AM 0
Share

Okay, Thanks a ton! ^^

avatar image Eric5h5 · Aug 02, 2014 at 04:50 AM 1
Share

The scene camera definitely still counts, unfortunately.

avatar image DRRosen3 · Feb 07, 2015 at 12:47 AM 0
Share

Which makes this answer incorrect for the question asked.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How can I make a gameobject partially invisible by distance? 2 Answers

Check if is object in camera field and not covered by other object 0 Answers

Camera rotation the same as player rotation 1 Answer

Forcing a GameObject to the highest depth (closest to camera) 2 Answers

How can I check when the centre of camera is looking at a gameobject? 2 Answers


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