Play now

воскресенье, 21 июня 2015 г.

Unity optimisation tips


My previous article was in russian. So this I decided to write in English. 

Maybe you have heard or even already played Alco Invaders on PC. 

But we also make Alco Invaders for mobiles. We tested it on wide range of devices:

-Kindle Fire 1,
-HTC One,
-Nexus 4, 
-iPhone 4S, 
-iPad mini 2, 
- Galaxy Tab 4 
- and even tablet Windows 8.1.

So on all this devices we tried to achieve 50-60 fps performance. And we did it! And on almost all devices graphic level is the same as in PC. Except Kindle Fire - it doesn't support bloom :)





When we only started to work on game - performance was horrible. 15-20 fps on Android. But we decided make good picture in any way. 




In my previous article I have wrote about core elements of optimisation. And this about polishing optimisation. Secret tricks, which can save 20-30 % of performance.

1. Never use .transform in circles

It was a great surprise, when I discovered this thing. But in Unity .transform = .GetComponent<Transform>().

Example is Bullet script 
https://gist.github.com/Oxygamer/20100d06e11a8494042d

And getting component cost much in circles. In my tests it save almost 12 % of performance. So, make variable of type Transform and assign it in the Awake() function.


2. Vector3.Distance() is expensive enough.

The reason - is Mathf.Sqrt() inside this function.

So if you can - better use predefined table of distances or calculate it not in Update().
I used such trick in my Hexagon particle system. 

If you have some kind of grid - calculate distances between all elements and write it to simple array float[].

It saves ~ 10 % performance.




3. Almost all physical is expensive.

Maybe it's obvious, but you can forget about physics of explosion, or bullets. Check all them and try not use much physical objects in one time.



4. Use delayed trash cleaning.

For this purpose better use .SetActive(false), store object to some list, and Destroy() it in pause or end of level. It depends of your game type.

5. Shaders - use VertexLit if you can.

Maybe it's not huge difference between VertexLit and Diffuse, but Specular cost much. The reason is per pixel light rendering in Diffuse/Specular shaders and per vertex in VertexLit.




6. Use Dictionary<key,value> for prefab storage.

It's useful when you searching object with some name or type.  For example you can use List<> for Editor, and then put all this prefabs to Dictionary<> on game start.

As example - Object Storage script

https://gist.github.com/Oxygamer/c93d958ae138aef607b2

P.S

Hope this tricks and techniques will be useful for you ! If you have some questions - write it in comments. I will help with gladness :)

3d artist searching !

Hi guys. We are launching Alco Invaders. It has in-game store with premium skins. So we searching for 3d-artists,who want sell skins here. We have statistic for all in game purchases Good feeling of humor is plus :)  #gamedev #unity

Привет всем! Мы запускаем Alco Invaders. Игра имеет свой магазин скинов. Мы ищем 3d дизайнеров, кто хочет  продавать свои скины в игре. Мы имеет статистику на все игровые покупки. 
Хорошее чувство юмора будет + !






Alco Invaders Help

Guys, we work on our game more then 1 year. And we want to share it to as much peoples as possible. So share our game, make review, and , yes, write to us if you want. Your support is invaluable.




пятница, 19 июня 2015 г.

Two Steves


Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma—which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown our your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

Steve Jobs