- Home /
Best way to optimize scene with multiple instances of a destroyable object
Ok, hopefully my question will make sense :)
Basically, I am making a platforming game for iOS and I am having issues with my frame rate. I recently discovered the "combine meshes" script and this has done WONDERS for my game, I can have massive levels with almost no performance hit...
Until I add in collectable coins. The trouble is, when you collect the coins I want to destroy them so they can't be collected again. Of course with the combine mesh scripts, the original coin and its collider etc is "destroyed" yet its representation in the combined mesh is still present. So I guess using the combine mesh script is out for these types of objects.
When I add in my coins, about 40 or so plain old Unity spheres (no scripts on them, just triggers), I take about a 10 FPS performance hit, and my scene has about 12 extra draw calls. for 40 spheres!
Is there any solution to this problem, something like a combine meshes script but for dynamic or destroyable objects?
I imagine pooling isn't the solution in this case, because they aren't being instantiated during the game, and when I destroy them, the FPS goes up!
All suggestions are welcome, I need to squeeze every FPS I can out of this game so I would truly appreciate any help!
Thanks
Answer by Garth-Smith · Mar 13, 2013 at 07:22 PM
How many materials are on these spheres? If 40 spheres are all using the same material, no transparencies, same scale, and are the same distance from the camera, it sounds like they should be just 1 draw call.
In my case, I had a "pulsing" animation playing on my coins that were causing all of them to have slightly different scales. This up'd my draw calls and caused a performance hit on the iPad 1. In that case we disabled the animations or made all the coins animate at the same time so they all had the same scale.
Thanks for the reply! They are all the same prefab and share the same material (a basic diffuse material). The only difference between them is their x and y positions :/
edit: Here is a weird twist: I just created 10-20 new spheres, and I still get the same performance hit. I then created 10-20 Cubes, and this brings the draw call down where it should be. Weird! I replace my old sphere coin prefab with a cube, and I am still getting a great draw call in unity editor, but when I build out to my device, I am still getting the same -10 FPS hit.
Your answer
Follow this Question
Related Questions
What is better to preserve, Draw calls or Tris? [Mobile] 4 Answers
ios and onGUi performance / alternatives? 1 Answer
How can I combine UV's with the Combine Children? 0 Answers
Draw calls and atlas size trade off 0 Answers
What is a reasonable number of draw calls relative to one hardware configuration ? 6 Answers