Playmaker Forum

PlayMaker Help & Tips => Android Help => Topic started by: rik on December 07, 2014, 08:59:49 AM

Title: destroy when the object was off the screen
Post by: rik 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
Title: Re: destroy when the object was off the screen
Post by: 4ppleseed 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.
Title: Re: destroy when the object was off the screen
Post by: Lane 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.
Title: Re: destroy when the object was off the screen
Post by: jeanfabre 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