playMaker

Author Topic: destroy when the object was off the screen  (Read 5566 times)

rik

  • Full Member
  • ***
  • Posts: 246
destroy when the object was off the screen
« on: December 07, 2014, 08:59:49 AM »
Hi can some make simple script to know when the object was invisible

api refe http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: destroy when the object was off the screen
« Reply #1 on: December 12, 2014, 09:54:23 AM »
OnBecameInvisible is a strange one (unless it's recently been fixed), if you can still see the object in the scene view, it's still 'visable'. It's not to do with the camera or screen size.

Best way to kill things once they leave the screen is:
Get screen height and width, save as variables.
Get objects position and if it's greater/less than the screen height or width, kill.
Probably best not to check this every frame. Maybe set up a loop for a check every 1 second.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: destroy when the object was off the screen
« Reply #2 on: December 12, 2014, 12:54:18 PM »
The Game Object Is Visible action should work.

Like 4appleseed said, watch out during tests because the scene view is also considered part of the cameras and contributes to whether something is considered visible or not.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: destroy when the object was off the screen
« Reply #3 on: April 15, 2016, 01:59:36 AM »
Hi,

 yep, but be very careful because in editor, the visibility also takes into account if the object is visible or not in the scene view, it's an easy miss.

Bye,

 Jean