- Home /
Lots of Skinned Characters iOS Performance
Hello,
I´ve got a question that probably cant be precisely answered, but I would appreciate your thoughts anyway. I see some games for iOS like Shadowgun (stunning graphics), Castle Master, Royal Revolt... Im not sure if the later 2 have been created using Unity, but.... my question is... How is it possible that with 20, 30 skinned characters on the screen (for Royal Revolt), possibly hundreds for Castle Master... how can iPhone 3GS handle that?
The reason for my doubt is that Im currently working on a game which I had to limit the number of characters in the screen to 5 for iPhone 3GS (player + 4 enemies) and that already leaves the game at 20-30 fps (which is terrible). I´ve read lots and lots about optimization for iOS and Mobile... about drawcalls, lights, bones, skins, UVs, shadows, transparencies... and I still dont know why my game is lagging so bad. Each enemy has around 200-400 tris, no more then 10 bones (usually less than that), 1 texture, 1 skin. The main character is a little more complex, about 14 bones, 700 tris... I am using Madfinger shared shaders (only diffuse simple (which is a kind of unlit shader and particles/alpha blended for unlit transparencies (Im completely noob regarding shaders)). There is actually not even 1 light in the game, not 1 shadow, drawcalls float between 20-50, quality settings are the simples possible (1 bone weight, no shadows, no anti alias, no nothing), I´ve made textures really small for test purposes and absolutelly no change in performance, I am no master coder but profiler tells me that my code uses close to nothing (by far the heaviest thing in my code is making enemy characters turn to face the player (which profiler indicates as transform.set_rotation() so... I dont know if there is anything I can do about it).
The game however relies on physics and its using around 5-10 fps, since there is a lot of throwing enemies around. There are no mesh colliders, the physics configs have been set to the most basic form, fixed frame rate increased to 0.1 with interpolation (also tested without interpolation, with 0.02 (default) and 0.04 timesteps, really made no difference in performance), Im not using raycasts for anything except input detection, everything else relies on triggers (and only on one shot events like Enter/Exit), almost no script uses Update() (only coroutines), iOS profiler informs that time on Update + Fixed Update + Coroutines is around 5-6ms... but there is no cpu-waits-gpu (eventually when there is, its a 2-3ms wait, but its rare), so I would believe this is a CPU limitation... (I dont use A* pathfinding... I dont use anything lol, things are as simple as they can be)
But, still, the game runs at 20-30 fps, frequently less than that considering attaking and skill uses... after reading so much Im almost to the point of thinking I am simply not capable to optimize this game any more... does anyone... please... have some ideas how these guys manage so many enemies/AIs, skinned and running around at the same time with absolutely no performance issues on 3GS?
Thank you for your attention, and sorry for the long (and desperate) post, Best regards, Allan
First thought - you are sure it's the characters slowing things down and not something in the environment? If you remove a character then the frame rate massively increases? If you just turn off the renderer for the enemies then does the frame rate increase?
Yes, I´ve already tested with only a cube serving as ground and completely removed the background, this resulted in a 4 fps gain only... the environment is very simple uses few textures and has around 4000 tris counting everything, its an arena so its not extensive. I´ve made the same test removing the HUD completely which resulted in another 4 fps. When I just enter the arena and its only the main char, HUD and environment, the game runs at 45-50 fps... each new enemy drops about 5-6 fps... =/
To be honest I havent tested just removing the character´s renderer and playing normally, I will test this ASAP and come back to you.
With all character renderers turned off, performance improved by 5-10 fps (the 5 characters on the screen). From 15-30 to 20-40 fps (depending on the intensity of the gameplay, skill uses, etc).
Considering how simple they are, I guess this is considerable improvement... since if I had 20 characters (like castle revolt) it would be a 20-40 fps gain... but... they are VERY simple... =/
No =/ They actually have 4 draw calls... 1 for the character, 1 for the main hand weapon, 1 for the offhand (even tho they use the same material), and one for the fake shadow... but how could I reduce this? I could make the sword and shield into the same mesh as the player, but this would increase the number of skinned polygons wont it? And the shadow... dont know how to make it another way