Hi there, I made a simple scene today, thought it will easily run at 60+ Fps and finally had a hard time understanding if I was missing something huge in optimisation or if I completely overestimated computers.
Here is my scene and the perfs
Explanation :
Each tile on the grid is a prefab made of 2 sprites ( background and border ). This is a 50x50 grid.
I made it like that because I need each tile to change its state individualy ( like color for exemple ).
Little black things are Ants, let’s call them agent. There are 300 agents, not moving. I spawn them with a script that instantiate a prefab. The prefab is composed of several sprites all stored in the same sheet. I made it because I planned to animate the agent. In fact I already did but I disable the animator when I saw the perf ( only win 2-3 fps btw for 300 agents, same with the collider2D ).
Strange fact : my CPU only run at 25% total. Lazy one
The only way I found to reach 60 fps, with the help of the profiler, was to disable enough sprite renderer …
Does it look normal perf to you ? I mean … This is not a huge map to play ( management game ) I wasn’t excepted such bad result.for “just” 2D sprite I tried to optimize. I read all what I found about optimization etc but that mainly focus 3D games ( batching ? I have 8K + saved by batching, due to prefab ? Doesn’t look bad to me but maybe i’m wrong ) and i’m pretty sure 300 meshes with the same vertex/tris count on a plane won’t result 20 fps.
I’m completely lost ! So, am i just bad at 2D or is it normal ? Let me know if I don’t give enough details ! Thanks in advance for any help
Probably best to have the ants be only a single animated sprite. That’s a lot of renderers for just one character.
That’s most likely what is causing the slowdown.
Thanks for the idea, will try the difference as soon as i have the time.
In fact I tried without any ants, and with 32x32 sprites the best I can do without any fps drop is a 50x50 grid.
so 50x50x2 = 5000 sprites maximum. Still looks bad to me. Feel like I miss something.
I’m not sure how you plan to animate the grid, but maybe if you make a single image grid as a background and disable inactive grid pieces will gain you some fps.
Also merging the grid edge and fill into a single sprite will cut your batching calls in half.
Though about that but i really want the player to choose the grid size, so this would lead to save 50 grid background ( I can scale the color background since it’s just a color but not the grid )… Maybe better to reduce the player choice to 3 ou 4 size.
I plan to allow the player to build an "object " per tile, so change the sprite tile when the player change it.
I’m going to merge the background, the grid and change the animation with a sprite sheet and post an update of the perf.
Edit : ° Merge the background in one image results 30 fps.
° +Switching with a sprite sheet give me 60+ fps but … Ow the lost of quality in the animation ( miss some interpolation ) is awfull
Just change dynamically the map texture when the player change it, and you’ll only have one sprite.
Huge brain burner to manage the map render with this and the collision logic separatly, but what a win for the perf. I can manage more than 5K ants now.