Troubles with game optimization for mobile and overall workflow in Unity
Hello everyone, I've been using Unity for several years now, but there have just been a few questions that came to my mind that I can't seem to find any credible answers for online.
The game I am currently working on is a simple endless runner game, with a playerobject which moves either to the left or right by swiping on the screen, and a street, which is made out of short segments, that are stacked behind each other and move below the player, creating an illusion of the player actually moving on the road.
I have always tried keeping my code optimized and simple, as such I for example am now using object pooling instead of instantiation and destruction for the road segments. Since the idea is to have Crossy Road style graphics, I dont need textures and very detailed meshes for the game. Even though the game runs fine on my Laptop, I only achieve about 15 FPS even on modern mobile devices. Looking at the batch amount in the Unity stats I get about 2000, which is apparently too much for mobile devices I have read. However, I cannot remove all of the lighting completely, which drops the batch count to about 1400, and there are barely any gameobjects I can mark as static so that unity can optimize them, because most things are moving and never standing still in the game anyways.
There are many mobile games with great graphics nowadays, so it just cannot be impossible. Therefore I have looked into using other shaders for the materials, but either the built in shaders that unity provides for mobile for some reason need a texture (even though I just need to change the solid color of a specific part of a mesh), and other shaders Ive found online either are not compiling anymore or look really strange ingame.
Furtherthemore, I do not really quite understand the workflow for using models made in Maxon Cinema 4D inside Unity. A friend is responsible for making all the models for the game in Cinema 4D, and he provides them to me in the .dae Collada format, which seemed to be the only format that somewhat worked when imported into Unity. However, upon importing the models, unity messes up all materials on the model, creates new materials in the assets folders, the models pivot point gets all messed up and after some while it just really starts to become a pain to work with models in Unity. Besides that, unity also imports the models submeshes as well, so the model basically ends up with many child objects in the game. This allows us to assign materials to specific parts of the model, however the fact that the model is now composed of many child objects probably makes the game performance suffer alot as well.
I've found the official Unity guides for mobile game optimization to not really go into detail much, and even google searching about the topic of mobile shaders or mobile optimization shows up very little results.
There is no point in continuing the work on the game if the overall structure of the game is unorganized and inefficient. I'd just be happy with having solid colors on the meshes which can also cast and receive hard shadows from the directional light in the scene, just like in may mobile games of this art style. In a professional matter, how would it rather be done: assign the materials for the model in Unity itself or prepare a seperate material file in the modelling program beforehand? My workflow just seems slow overall, and most tutorials don't go onto further detail about this issue.
I know this is alot to ask for, but getting a reference point to start troubleshooting would be a great start for now. Anyways, please excuse me for such a complex and specific question, but I really just ran out of ideas to try. Any help is appreciated!
Answer by Bip901 · Jun 11, 2018 at 11:55 AM
Hi UselessCookie. From what you described it looks like most of the trouble comes from your models.
Tips:
Unity supports .fbx and .blend files. I love Blender because it's a free, professional piece of software. I suggest you or your friend learn how to use it, because it has none of the pivot and multiple gameobjects issues you described.
Perhaps your models have too many polygons. When you remodel the game, use the least amount of polygons possible.
Reduce the material variety to the minimum possible.
Play your game for a bit, then exit play mode and look at the Profiler window in Unity. It will point out what uses the most performance. It could even be one of your own scripts!
If you haven't already, go to edit > quality settings and change the quality to the lowest possible.
You said Unity was messing up the materials and creating new folders. Click an imported model in the Project window, and in the Inspector click the "Materials" tab. There, you can uncheck the "import materials" setting.
Thank you for your suggestions, I'll definitely give .fbx a try and maybe look into switching to Blender. I however dont think the models have too many polygons, as they are pretty much just roughly composed of blocks. As far as the profiler goes, Ive already given that a try a few weeks back, if I recall correctly graphics rendering in general was using up quite a bit of runtime, maybe it makes sense to just use unlit materials overall? Everything would look much less detailed, and I believe shadows wouldnt work.
I'll let you know if your tips improved anything!
No problem. Use unlit materials only if you're desperate and nothing else works. A lot of mobile games run smoothly without having to use unlit materials.
Your answer
Follow this Question
Related Questions
Optimization Help Please? 1 Answer
Materials appear different in different projects 0 Answers
Weird material or shader problem on mobile 0 Answers
Converting LWRP Shader Graphs to work with Built-in Renderer 0 Answers
Hair material problem 0 Answers