[tips] OnBecameInvisible() to destroy a laser

I found a good alternative, so I want to share it.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html

public class Laser : MonoBehaviour     
{
   void OnBecameInvisible() 
   {
       Destroy(gameObject); 
   }
}
2 Likes

Nice. Reminds me of a recent article about rendering efficiency in modern games (Kotaku article). I guess this would be used to implement Frustum Culling, which I learnt about in the aforementioned article.

Privacy & Terms