- Home /
how to turn of the mesh renderer when the player isn't looking
Hi all
I'm looking for a short "if statement", or 2, which can tell weather the camera is facing it or not/weather the camera can see it. As i'm making an android game I would want quite powerful graphics but still able to render on about 80Mg of RAM.
thanks in advanced.
You should not implement this manually. As stated, Unity already does this automatically out of the box. If you add this in yourself on top of the existing functionality, you will only generate additional overhead for literally no effect at all.
Answer by Piflik · Jan 02, 2013 at 08:54 PM
Objects not in view aren't rendered. No need to turn of the renderer.
Answer by Golan2781 · Jan 02, 2013 at 08:58 PM
What you are looking for is called frustum culling - unity implements that by default in its camera ((see section Clip Planes). The somewhat more advanced occlusion culling is a default feature for Unity Pro only, though.
Answer by Julien-Lynge · Jan 02, 2013 at 08:52 PM
Monobehviour has two events that you can use: OnBecameVisible and OnBecameInvisible. Here's the script reference:
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnBecameVisible.html
I tried this and when ever I looked back at the object it didn't turn back on
I would think that if you disabled the renderer it doesn't become visible because it's invisible...