Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 crazydragonking99 · May 27, 2014 at 10:24 PM · camerafollow playeronbecameinvisible

OnBecameInvisible only running when game stops

I am working on a 2d game where the orthographic camera follows the player. I am attempting to use OnBecameInvisible to destroy objects as they leave the camera's view (yes I know this is inefficient, I am just trying to get it working). However, OnBecameInvisible does not run until I stop the program, no matter how far the camera gets away from the objects. This is the only camera I have, so I was wondering what might be causing this and what checks I can do to identify the problem.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · May 30, 2014 at 02:27 AM

You must disable the scene view camera. Close the scene view tab or just make sure it's not being rendered — I have the scene view and profiler as different tabs for the same pane, so if I need camera visibility stuff to work, I switch to the profiler.

Comment
Add comment · 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
0

Answer by meat5000 · May 27, 2014 at 10:32 PM

Try this instead

http://docs.unity3d.com/ScriptReference/Renderer-isVisible.html

Comment
Add comment · Show 4 · 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 crazydragonking99 · May 29, 2014 at 06:05 PM 0
Share

I understand what isVisible does, but I am unclear how this will help me. That being said, what function should I be using it in? I am getting weird results in both Update and FixedUpdate

avatar image meat5000 ♦ · May 29, 2014 at 06:57 PM 0
Share

Its basically the same except you handle by check ins$$anonymous$$d of by function.

On becomes visible, set a flag that it has appeared on screen (To avoid destroying to early). Is it now invisible? Destroy.

I believe you can use this in any function. At least I think so.

Are you testing this in editor? I believe rendering in Scene view counts towards its 'isVisible' status.

avatar image crazydragonking99 · May 30, 2014 at 01:32 AM 0
Share

I am testing this with the Scene tab and the Game tab side by side and have the same results in both.. What exactly is 'scene view'? Any link I have found to it in the documentation 404's me. Do you mean that my view of everything in the editor counts as visible?

avatar image alonsoGarrote · Sep 07, 2015 at 05:26 PM 0
Share

Hi there, Im having the same problem. Im using a simple OnBecameVisible() and OnBecameInvisible() to make the Skinned$$anonymous$$eshRenderer change materials when player is not visible. I only get the Debug.Log for OnBecameVisible() when I play the scene and OnBecameInvisible() ONLY when I stop the scene. Any ideas on why is this happening? Regards,

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Toggle map/Camera [JS] 1 Answer

Camera position changes after shake 1 Answer

Problem vid GuiTexture 0 Answers

How to rotate the camera smoothly for just 1 second? 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