- Home /
How to optimize multiple sprites,How to optimize multiple sprites?
Hi, I'm currently developing an android game where I have to spawn in bunch of small sprites and connect them together. Now here is the problem: I made it possible, but I realized the performance is really bad. I would like to know how to optimize them. I actually found a way of doing it, which was to merge multiple sprites into one. Although I couldn't find a way to merge them in the game.
So I would like to know how to optimize multiple sprites into one, in order to improve performance. I would also like to know if it is possible for me to merge multiple sprites into one in the game. If so, how?
Answer by NanoEngine · Aug 24, 2017 at 04:37 PM
Solved merging sprites and colliders helped fps.
Answer by TheSOULDev · Aug 22, 2017 at 07:25 PM
You have performance issues probably because you're just instantiating them. One solution is to create a single sprite in an image editing tool and instantiate that, or object pool all those sprites at the start and then reuse them. The first one will have the best performance, while the second one will be the easiest to implement.
The problem is not because i'm instantiating them, since the instantiation step is done in Start() method. I thought that something else might cause performance spikes, so I tested in a fresh new project with around 200 small sprites, and as I expected the multiple sprites were causing the problem for sure.
The multiple sprites are definitely not the problem - I tested 1000 of them spawned on start moving them randomly around and I had 60 FPS. Now either you have an extremely slow device, or your approach is not good. Instantiating 1000 of them will make it lag a bit for less than a second, but the sprites existing and moving aren't the problem. Check the profiler window, here is $$anonymous$$e with 1k 512x512 sprites
Well, I'm not sure, but you probably have vsync on or something. and I'm testing on a mobile device. and it does kill fps. It's stupid to make a game that can only run well on specific devices. I do not want to argue with you about whether or not multiple sprites kill fps, but for me it does, and I have tested it multiple times (as I did again on different device). I'm pretty sure this happenend to someone else.
Your answer
Follow this Question
Related Questions
Expand Object On Touch? Someone please help me 1 Answer
Having just one scene in the game: is it inefficient? 2 Answers
Get sprites from a Texture2D 1 Answer
Duplication Problem. Please help. 1 Answer
Gravely need some optimization tips 3 Answers