- Home /
Disable objects around the player?
I've been trying to make a game for Android and my main focus is performance and how I can avoid overloading the device. I was thinking what might improve the FPS is to disable objects that are a certain distance away from the player. The only way I can think of how to do it is to do a GameObject.Find() to find the distance of the player, but since I am doing this for all objects, calling that method so many times I would think actually hurt the performance instead.
What would be the best way to optimize my game?
It is only for pro. Just don't have such a big map and it shouldn't overload an android device
Answer by Statement · Dec 23, 2013 at 06:10 PM
Consider using these callbacks:
-
This message is sent to all scripts attached to the renderer. OnBecameVisible and OnBecameInvisible is useful to avoid computations that are only necessary when the object is visible.
Examples:
void OnBecameVisible() {
enabled = true;
}
void OnBecameInvisible() {
enabled = false;
}
Answer by Zach3ryH · Dec 23, 2013 at 06:48 PM
I would agree with Statement about the visble methods. It seems like you are trying to increase the overall performance of your game and this document is a good start if you haven't seen it already. http://docs.unity3d.com/Documentation/Manual/OptimizingGraphicsPerformance.html