- Home /
Create thousands of GameObject
Hi,
I am building an iPAD app where I need to draw many small ~=10000 GameObjects. I am using "Mobile-Particles->Alpha Blended "shader. I create the objects in script using Instance(). My problem: the fps! It drops to 8 when 4000 objects are created. I have read through the forums and used the mobile shaders, created object pool (objects die and live) etc..
Any suggestions how may I improve my fps? Is there any maximum number of objects (or number of polygons that can be rendered) which can be created on iPAD?
I am using Unity Pro, iPhone Pro version.
Thank you...
Are there any way you can fake it, combine them to clusters of objects ins$$anonymous$$d?
Answer by doug__ · Dec 11, 2012 at 02:31 AM
The issue isn't the hardware, it's that GameObjects suck.
They're great if you have a small number of objects that are lightly animated, but they suck, specifically, when you have a lot of them or have to regularly update the shader or mesh for the object.
You could try to use Graphics.RenderMesh() instead of game objects.
To give you some kind of comparison, I get 6 FPS using GameObjects and 40-50 FPS using RenderMesh on 5000 tiny objects with dynamic meshes moving around the scene.
Downside: You can't use any components for these, can't raycast into them, can't collide them, can't modify them in the scene editor.
...but it is really fast. REALLY fast.
So... I guess it depends what you're doing. If these are just 'sparkle' effects that are shiny and don't interact with other things, use RenderMesh. Even if it's like a bullet-hell game, it's probably worth doing it and manually keeping track of intersections (much more efficient that using colliders where everything has to collide with everything else).
...but if you're doing something like drawing a bunch of blocks in a brick wall, it's probably not an option I guess.