Ok so you read the title, this is my code so far:
function OnBecameInvisible() {
renderer.enabled = false;
}
So I tried OnBecameVisible but that doesn’t work if the object is invisible or renderer is disabled. I thought a Raycast might work but was wondering if there was another better way to do it. Thanks!
would it be beneficial then?
– MrLolEthanYou can technically calculate the angle between the vector to the object and the camera and if it's greater then the view angle, disable it's renderer. However, as MrLeap already said, this is something that Unity does automatically for you. You can test against renderer.isVisible to enable/disable scripts etc. for performance though, which can certainly be useful for optimization purposes.
– asafsitner