- Home /
Should large amounts of static objects outside of the camera’s clipping planes range be lagging my iOS game?
Hello, so I’ve been busily developing a 3D game with a top down one-direction camera for iOS and its been performing wonderfully on my iphone 4. However upon testing the game in a much larger scene with a lot more scenery objects the game lags itself into oblivion. (Phone-side only lag, no such issues when running on the mac)
These additional scenery objects are not within the camera’s clipping planes range and should presumably not be being rendered. Furthermore these objects are mostly just basic primitives (Cubes and such), with some of them being textured planes instead. They have no scripts, do not get initiated or destroyed and shouldn’t be being referenced by any other scripts.
I had assumed, perhaps foolishly, that because of Unity’s Frustum Culling the performance impact of a large level populated with nothing but static scenery (both in the sense that the objects just sit there, and the sense that I’ve tried toggling static on them) would be minimal. However as the game performs fine when I make two-thirds of the level’s scenery inactive, I’m guessing I was wrong.
(Just to clarify the lag is stopped by making objects outside of the camera’s clipping range inactive, the same amount of triangles are visible on the screen as were prior to the lag)
Obviously I’m no expert and a little confused to why this is happening, so I’d just like to make sure that I’m barking up the right tree here, and that large amounts of scenery not currently being rendered does in fact put a lot of processing strain on the platform. Just to make sure there isn’t some kind of hidden other system in my game responsible for this lag.
Assuming it is simply the sheer number of objects in the level causing my issue, any suggestions on how I could work around this would be welcome, other then just reducing the size of the level ^^. For example I’m toying with the idea of making the level’s scenery activate and deactivate as the player moves round it, since the level seems to work fine with most of the off screen scenery inactive.
Apologies for the wall of text, just trying to make my situation as clear as possible, thanks in advance for any and all responses.
Are you running Pro? If so profile it.
The frustum culling takes time...
As for suggestions - do your own logic for turning these extra items on and off if you can... It could also be trying to batch them and creating an unholy mess of the frustum bounds check (but that's less likely).
Only using basic i'm afraid.
Is there any way for me to check if unity is trying to batch them?
Thinking back the guy who made the scene did make the entire level under one parent object for organisation's sake, could that be causing them to be batched? (Though i'm not entirely certain on what that means TBH ^^)
You say the frustum culling takes time... It is an automated process though? I'm not missing some kind of setting for it somewhere which might have been set incorrectly and be resulting in my problem.
Frustum culling is automatic and cannot be disabled (nor should it be). You can disable static and dynamic batching in the Player Settings which might be worth a go.
Putting everything under a parent shouldn't be a problem - things batch which are in proximity and share a material. Doing your own "turning things off" would be a good idea if you can find conditions where things should not be displayed.
Answer by emiller100 · Mar 29, 2013 at 07:10 PM
Frustrum culling happens automatically. In the editor it will not if one of the views is also showing the objects. Did you actually deploy your game to the device? Do your objects have scripts? The only thing the culling will turn off is the renderer. The scripts attached will still run.
The objects have no scripts attached to them and the game is being deployed to an iphone4, it does not lag whilst played undeployed on the development mac.
Your answer
Follow this Question
Related Questions
iOS: Performance gain by disabling accelerometer? 1 Answer
How to improve FPS on mobile? 1 Answer
Why did my render time increase after lowering the vertex count? 2 Answers
Lots of Skinned Characters iOS Performance 0 Answers
Are there any performance differences between a timer and using Invoke? 1 Answer