8 Eylül 2016 Perşembe

Power of Unity3D Editor

I have already written about the decision on moving to Unity3D in this post. Now it is time to go over all the main items of mobile game development with Unity. There are plenty of documentation, tutorials on how to make game development, I strongly recommend to take a look if you want to learn details of this beast.  Here I am going to summarise our experience on creating real-time multiplayer board games on Unity.

As you can understand from the title, first point will be the Editor of Unity. It is very powerful by default and highly customizable. Which means it can even be more powerful in your hands.

I will not tell you about the details of the editor’s basic features. But I can easily say that, you will do almost everything (except coding) inside the editor. Configuring the game scene(s), attaching your codebase to game objects (characters, items, ui elements etc...), creating animations and setting input triggers, choosing preferences, integrating with version control system, preparing your project for a build. As I said almost everything :)

Gin Rummy Plus under the hood :)

The most common and useful windows are shown in my custom (not the default) positions above. This is the arrangement that I am using, it gives me practical access to the the most common windows. Actually I am not sure if there is a best practice on this, because even in our team almost each one of us using different arrangements. I guess we are going to find sweet spots soon :)

The Scene View allows you to visually navigate and edit your scene. The scene view can show a 3D or 2D perspective, depending on the type of project you are working on. Find out more about the Scene View. Actually I am using this section with The Console Window, because while running the game, I am looking either the scene or the logs.

The Game View is rendered from the Camera(s) in your game. It is representative of your final, published game. You will need to use one or more Cameras to control what the player actually sees when they are playing your game. Find out more about the Game View. Similarly I am sharing this section with The Animator Window.

The Hierarchy Window is a hierarchical text representation of every object in the scene. Each item in the scene has an entry in the hierarchy, so the two windows are inherently linked. The hierarchy reveals the structure of how objects are attached to one another. Find out more about the Hierarchy Window.

The Inspector Window allows you to view and edit all the properties of the currently selected object. Because different types of objects have different sets of properties, the layout and contents of the inspector window will vary. Find out more about the Inspector Window. I have another custom window (MockMessenger) here to replicate server socket messages to the game on runtime. I will tell more about custom windows soon.

The Project Window displays your library of assets that are available to use in your project. When you import assets into your project, they appear here. Find out more about the Project Window. And of course I am sharing this section with Unit Test Runner Window. (I will have a separate test section / post.)

The other very important thing about Editor is extending the editor. It is quite easy to customize the editor, and can be very useful. Unity lets you extend the editor with your own custom inspectors and editor windows and you can define how properties are displayed in the inspector. There are various types of customization that we have used in our games. I will give you a few simple ones:


Custom Menu Items 


We have created a few functionality and put them under custom Peak Games menu item. That enables us to run those functionalities during runtime and/or development time. To show you how useful they are, let me tell you about three of them: ReconnectDisconnect, Send To Background functions. 

Since we are making realtime synchronous mobile games, it is very frequent to have connection drops, very quick reconnections or sending game to background because of a phone call or something. So it is inevitable to face these issues during the game play. Like other games, we have our own solutions, catch mechanism in different situations like this. But having the solution is not enough, it should be consistent and available on every part of the game. With these custom menu items we can simulate these issues on our games whenever we want on different scenarios and different parts of the game during the runtime (kind of a monkey test).


Custom Windows



Next is custom windows, you can create any number of custom editor windows for your game. These behave just like the Inspector, Scene or any other built-in ones. This is a great way to add a user interface to a sub-system for your game.

Again I will give a real example from our games. We have created a custom window MockMessenger, it is not that sophisticated but to the point. The purpose is replicate server socket messages to the game on runtime.

Like any other software project, we divide the projects into smaller features, and even more smaller tiny tasks. So while we are developing a feature or fixing a bug, we are working on a specific part of the game. And in our case, most of the time that part is highly integrated with server side. Instead of configuring a specific development server or a local server, we are using this window to send server messages to our game. With this window and the function underneath we can send a single message to our game like it is coming from the connected server. 

Like sending a single message, we can send multiple messages at once and save that scenario to a file and replay it over and over again. Even we can configure the exact receive times of those messages , so that we can mimic weird socket packages' receive times. As you know sometimes you can get multiple packages in a few milliseconds and wait for the next ones more than ten seconds. 

Since socket connection is the fundamental part of our games, it is very crucial for us to replicate these situations very quickly and without big efforts. As you can guess we are using this window very frequently not just developing a new feature, but also simulating or reproducing a real issue. So with this simple window we gain a lot of time and effort.


Customize Hierarchy Window


Other customization that we have done is to show additional information in the hierarchy window. It makes things easier to track during the game play. I guess you already got that we really love card games :) 

In a card game, Card (class) is the main character of the game along with Hand, Deck and Pile of course. And it is very important for us to track a card object is enabled or disabled in the game play scene or the conceptual and physical location of the card like is it in the Hand, or is it in the Deck or Pile. 

While playing the game, cards are moving between Deck, Hand and Pile. It would be very useful tracking the cards in the editor hierarchy window. For example, by looking at the hierarchy window I want to see the number of active cards which are children of deck or pile or hand. Actually my colleague has already explained this customization in detail.


These are very simple examples just to show you the main idea. You can create much more sophisticated customizations, for instance once we had developed a level editor inside the Unity for an experimental endless runner game.

As last word, it is your imagination and needs that would lead you to make editor customizations. The main idea is to ease and quicken the development of a Unity game.

Now let's write some code...

6 Eylül 2016 Salı

Why do we move to Unity3D?

As I explained in my previous post, I am starting a series of Unity related posts. The idea is create every section of my talk on voxxed days belgrade as a separate blog post. So here it is the first one. Enjoy :)

Before diving into the reasons behind this decision. Let me give you a little background about Peak Games and mobile team.

Peak Games founded at 2010 to create social games on social platforms especially on Facebook. A bunch of very successful games has been developed and published on Turkish market. After one and half years, Peak Games was one of the companies realise that mobile will be the platform for social / casual free-to-play games. And we have established a mobile team. Back then it was very hard to find mobile game developers,  even it was very hard to find experienced mobile developers. Actually myself was a senior backend java developer who wants to be mobile developer. So we were aware that it would be a very tough learning process for us.

Our first mission as mobile team was to create ios and android platforms for our existing titles. With a lot of discussions we had decided to move native on these platforms. And we had tried different technologies like cocos-2d and uikit for ios platforms, and c++ (with custom engine) and libgdx for android platforms. I will not go deep on these technologies and decisions that we had. But I can easily say that after two years, we were very happy and comfortable with UIKit (for ios) and libGDX (for android). We had created 10+ games using these technologies, and created 20+ reusable libraries common on these games. With all these efforts and experience we had reduced the time of developing a similar game to one third according to first game that we had build. And I don't want to be humble about these games, they are not mediocre games, they are very very successful games not just in Turkish market, but also in US market. Today hundreds of thousands players are playing these games.

In short, we were happy with the technology, we had the experience, and common libraries for future games. And also we are happy with the end result (I mean the games as whole). We had no doubt that we could build even better games with these technologies. So I guess you wonder, what makes us to think to change the technology behind these games, libraries and experience.

The main reason was the nature of free-to-play games. You have to improve your free-to-play game continuously. Otherwise it would die very soon. We are still adding very big features, or making very big changes on our first titles that we had build more than two years ago. With this reason we have to code our games very clean and readable. We have to use common patterns to solve the problems. This is another topic that I can speak forever :) 

My point is having multiple codebases for the same game (ios or android) causes some issues. First of all it make things slow in overall. Since it has different codebases, both of them have different issues. And they have different solutions for same problems. It makes the release planning and enabling/disabling features very hard. Most importantly we want both platforms exactly same as much as possible. But with different platforms, technologies, codebases and different developers it is not possible to get the same results in ios and android. So we have three main reasons:
  • We want to be quicker on the initial development of the game. 
  • And also we want to be quicker and consistent  while improving the game continuously. 
  • We want to have one single codebase for two platforms.
That is why we have decided to go cross platform development for our new games. We were going to keep the existing games in their existing technologies, but we were going to build new games in selected cross platform solution. And also we would not touch our canvas platforms (which is written in AS3 action script technologies). Because even ios and android are different platforms, they are both mobile and we need to give same user experience on these platforms. But canvas is totally different and has to have different user experience.

So let's come to our options for cross platform development. I know that there more than these options to consider but I just list the ones that are in our short list :)


Haxe (with custom game engine)


Positive points :)
  • Run Time Performance is real good. Let me give you a real example from one of our games: We had a path finding algorithm written in AS3 and wanted to optimize the performance. By just converting the code to Haxe the performance was increased around 10 times, which is a shocking great result.
  • Dynamic typing languages are very efficient to hacking things or creating quick and dirty projects. But if you are creating a long living game to be able to maintain it for years. Than you should definitely have static typed language to be able add new features, make bug fixes without breaking other parts.
  • If you have experienced AS3 engineers, that means adaptation would be very quick and seamless. We all know that the de facto technology of games for canvas is AS3. Most of the social/online gaming companies has very experienced and valuable AS3 engineers. To adapt that experience especially to mobile platforms is very important.
  • Theoretically with Haxe, you can re-use the code not just in client technologies but also in server side. This is very important especially if you are building multiplayer real-time synchronous games like us. That means you need to have same game rules / game logic both in client and server.
  • With Haxe you can use different game engine underneath, you don’t need to stick with the same game engine technology for all kinds of your games. Think about that you are building different games in different genres. With Haxe you can have same language but different game engines for different game genres. (I agree that this is something that you need to avoid as much as possible, but having the ability is always good ☺).
Negative points :(
  • Since it is not a popular language/technology, it will be very difficult to find someone experienced on Haxe. And also it will not be easy to convince good talents to learn and give commitment on Haxe.
  • There are couple of initiatives for pure Haxe IDE (like HIDE) and also some plugins for existing popular IDEs (like IntelliJ Idea). But it seems to be a pain to establish a fully functional development environment with unit testing support, quick and robust simulator/emulator support, automated UI testing support and CI support.
  • The documentation is quite weak. Actually Haxe is not that young, it is almost 10 years old. So I would expect better and much more rich documentation. And when it is compared to alternatives, the community is not that big. So with Haxe you will by your own hand, it might be very difficult to get support in emergent cases.
  • We couldn’t find any very successful top grossing game projects written with Haxe (except the ones in the site). So I guess, it is a very important indicator that it has not enough support or belief on technology.
  • As far as  understand it is not that easy to use Haxe for prototyping a new game idea. That means you need to have another technology/solution for prototyping.


Unity3D (with C# Language)


Positive points :)
  • Prototyping is very fast and it gives the nearly real feeling of the game play before the production.
  • With all integrated components (editor, animator, debugger...) you can base your entire game production pipeline over Unity. What I mean is your product managers, level editors, visual designers, sound and animation experts can work on Unity. So that integration of all these parts can easily be done.
  • With very powerful editor, simulator and debugger, as a developer creating game scenes and tweaking tiny details is very handy.
  • With the power of language C#, you can leverage most of the C# libraries and community. And also it enables you to create best practice game architecture in means of engineering. And entity/component driven architecture helps to build robust and flexible games.
  • It has arguably good support and community options. There are a lot of engineers (from indie world to very big game companies), who works on Unity, creates games and develops the community.
  • It has very great asset store, it is not always the case to use those assets as it is, but it gives really good starting point.
  • Back then it was one third of all top grossing mobile games were build with Unity3D, nowadays it is almost half of it.
Negative points :(
  • Right now there is very limited canvas support (with Unity plugin or WebGL) but I believe it will change soon.
  • Optimizing the performance is very difficult, and out of the box it is not performant. You will always need to make some optimization for performance issues.
  • Prototyping very fast but finalizing as a complete product and polishing it, is not that easy. You have to be ready to spend a lot of time for just polishing the game.
  • It is not easy to work Unity as a team. No problem with C# source code but for the other components (like prefabs, scenes) cannot be worked collaboratively by its nature.
  • As I mentioned C# is great and powerful language. But you should always keep in mind that running the C# code on Mono Runtime has some limitations. And also Mono Develop itself is one of the downside of Unity.


Cocos2d-x


Positive points :)
  • Open source and highly contributed game development framework and game engine.
  • It is a library based platform on top of powerful language C++
  • Since it is based on a very low level language of our days,  performance would be very satisfying.
  • Creating a game with it is very satisfying from engineering point of view.
  • Optimised for 2D games.
Negative points :(
  • For me the main negative point is again the language C++. It is very difficult to find someone who knows C++ or who wants to learn C++ :( at least it is the case in Turkiye.
  • It doesn't have a good game scene or animation editor etc... You have to use different 3rd party tools for this purposes and find ways to integrate with cocos-2dx. It is possible but not easy.
  • In long term it might be a good decision, but in short or mid term, it requires a lot of effort to create a game. Even create a prototype.


LibGDX with RoboVM


Before pros and cons I want to mention that, we had produced and published a successful game with this option. And you will see that all the good points come from libGDX, and all bad points from RoboVM. 

Positive points :)
  • Half of the mobile team (Android team) is already using libGDX as the primary technology for our native Android games.
  • There are quite amount of reusable components and libraries based on libGDX. We are already using them in production, so they are mature enough.
  • Both RoboVM and libGDX is open source. And there are many contributors especially for libGDX, it is always getting better.
  • libGDX has very robust and quick simulator support, especially when you compare to emulator on Android Studio.
  • Optimized for 2D games which is important for us.

Negative points :(
  • RoboVM was an ongoing project and it was changing a lot and frequently.
  • There were very limited support from community to RoboVM
  • Since it was kind of beta versions, it has very limited documentation.
  • We were spending a lot of effort and time to understand and integrate RoboVM.
  • Bindings from Java to Objetive-C was very painful and very very limited.
  • One last point project is stopped. It is acquired by Xamarin. And Xamarin aquired by Microsoft. And they decided to stop the project. It is open source but there are no real contribution any more.

Conclusion


After all these positive / negative points it was very difficult to foresee the future of these technologies. So what we have decided is to give a try on Unity3D at least for a few games. And then we could discuss further with real game development experience. And we had developed multiple games with Unity3D, we are happy with the result so far. I think we will stick with this decision especially after we see that it is becoming de facto technology both for indie developers and bigger game studios like EA Games, Blizzard etc...

So first section is done, I hope you enjoyed it. Now I will move to next sections that I am going to tell you about the experience on game development with Unity3D.


15 Temmuz 2016 Cuma

Voxxed Days - Istanbul & Belgrad

Antwerp / Belcika
Java Dunyasinda Devoxx onemli bir organizasyondur. Dunyanin her yerinden cok onemli konusmacilar ve katilimcilar bu etkinlikte bulusurlar. Yeni teknolojileri ogrenir, tartisir ve fikir alis verisinde bulunurlar. Ben de Sony yillarimda bir kez bu etkinlige katilma sansi bulmustum. 

Devoxx 2010'da aldigim notlara soyle hizlica goz gezdirince, mobil teknolojiler, cloud sistemler ve big-data kavramlarinin en trend teknolojiler oldugunu soyleyebilirim.

Voxxed Days ise Devoxx'un cesitli ulke ve sehirlerdeki lokal versiyonudur diyebiliriz.  Hatta Istanbul da bu sehirler arasinda. Voxxed Days Istanbul kodcu.com'un gayretleri ile son iki senedir basarili bir sekilde gerceklestiriliyor. Buradan kendilerine tesekkur ediyorum. Ayni sekilde Peak Games olarak biz de bu organizasyona hem ana sponsor olarak, hem de konusmacilar ile katkida bulunmaya calisiyoruz.

Voxxed Days Istanbul 2015 konusmacilarindan birisi de bendim. Peak Games'te mobil takim olarak cok onem verdigimiz "Code Review" uzerine bir konusma yapmistim. Youtube linkini ve yaptigim sunumu paylasiyorum.



Bu sene ise (Voxxed Days Istanbul 2016'da) calisma arkadasim Serdar Sahin,  Peak Games'in Big Data evrimini cok guzel bir sunum ile anlatti, izlemenizi tavsiye ederim.



Simdi gelelim asil haber vermek istedigim noktaya :)

Bu sene kisisel olarak kedime, (daha bir cok hedefin yaninda) ikisi yurtici, birisi yurtdisinda olmak uzere toplam uc (sirket disi) sunum hedefi koymustum. Bunlarin yurtici olanlarini ITU ve Bilkent Universitelerinde yaptigim sunumlarla tamamladim. Icim rahat :)

Yurtdisi icin once 360 | iDev Organizasyonuna, aklimda olan bir konu ile basvuruda bulundum, ama malesef kabul ettiremedim, belki onumuzdeki yillarda tekrar denerim. Sonrasinda ise Voxxed Days Belgrad icin baska bir konu ile basvuruda bulundum ve (mutlu haber) kabul edildim. 28-30 Eylul 2016 tarihlerinde Unity ile oyun gelistirmeye giris konulu bir sunum yapacagim. Haydi hayirlisi...

Bu sunumun calismalarina yavas yavas basladim. Kafamda ara konu basliklarini cikariyorum, hangi konu  icin ne ornekler verecegimi planlamaya calisiyorum. Benim icin gercekten zorlayici bir tecrube olacagi kesin, iyi hazirlanmak ve ici dolu birseyler sunmak istiyorum. Onumde 11 hafta gibi yeterli bir sure var gibi gorunuyor.

Bu calismalar kapsaminda, aklimda soyle bir plan var. Sunum genelinde toplam 6 - 10 arasi onemli noktadan bahsetmek istiyorum. Bu konulara tek tek hazirlanirken, her birisi icin ayri bir blog yazisi olusturmayi dusunuyorum. Boylelikle hem hazirlanmis olacagim, hem de bu hazirlik kapsaminda yapacagim calismayi burada paylasarak, (pek de ilgilenemedigim) blogumu canlandirmis olacagim. Isallah...

Tabii soylememe gerek yok ama sunum Ingilizce olacak ve dolayisiyla bu calisma kapsamindaki blog yazilarim da Ingilizce olacak.

Gerek bu konu ile ilgili, gerekse diger yazilarimla ilgili yorumlariniz, benim daha iyi bir calisma ortaya koyabilmem icin cok onemli. O yuzden yorum yapin, cekinmeyin...

27 Nisan 2016 Çarşamba

Bilkent CTIS Lunch Time Seminar

Dun Peak Games'ten 5 arkadas, Bilkent Universitesi CTIS bolumunun daveti ile sabahin ilk saatlerinde Ankara yollarina dustuk. Yollarda yasadiklarimizi, taksici ve trafik maceralerimizi bir kenara birakiyorum. Biraz yorucu ama ayni zamanda hem zevkli, hem de yararli oldugunu dusundugum bir ziyaret oldu.

bu pattern'ler bizden sorulur

Amacimiz hem ogrencilere faydali olacak konulardan bahsetmek, hem de Bilkent Univertistesi ile iliskilerimizi artirmak. Cunku bu universitelerden yetisen kisilerle oyunlarimizi gelistiriyoruz. Is hayatinda karsilastigimiz sikintilarimizi, her gun cozmek zorunda oldugumuz  sorunlarimizi onlarla paylasmak ogrenciler acisindan ileride onlari nasil bir is hayati bekliyor konusunda yararli oluyor. Ayrica bizim acimizdan ise ogrencilerin okullarda neler ogrendiklerini, oyun sektoru ile ilgilerinin ne derecede oldugunu gormemizi sagliyor.

Is arkadasim Ilkin ile birlikte ne hazirlayabiliriz diye biraz kafa yorduktan sonra hem yaptigimiz is ile alakali olsun, hem yararli olsun,  hem oyun dunyasindan birseyler icersin diye karar verdik. Bir saatlik bir sunumda konulari derinlemesine inceleyemiyorsun malesef. O yuzden de,  icinde ogrencilere fikir verebilecek, ilgi uyandirabilecek, ilerisi icin baslangic olabilecek bazi noktalar barindiran, tecrubelerimizden ornekler de koydugumuz asagidaki sunumu hazirladik.


Daha once de bir cok kereler bu tarz organizasyonlarla, Turkiye'nin onde gelen universiteleri ile bulusmalar, soylesiler, sunumlar gerceklestirdik. Sahsim adina ve Peak Games olarak bu sekilde devam etmeyi dusunuyoruz. Umarim ogrenciler acisindan da yararli oluyordur.

Ayrica universite ortaminda olmak, o havayi solumak, kantinde bir cay icmek beni tekrar ogrencilik zamanlarima goturdu. Kantinde birseyler yerken, herkes kendi okul yillarina gitti, guzel sohbetler oldu, tam bir gunun bonusu oldu.

Tekrardan daveti icin Bilkent Universitesi CTIS bolumune ve Dr. Erkan Ucar 'a cok tesekkur ederiz.

7 Mart 2015 Cumartesi

Hepimiz Yaslanacagiz


Sarp'la ara ara parka gidiyoruz, orada kosturmayi, kumlarla oynamayi, salincaga, kaydiraga binmeyi falan cok seviyor. Sevmek ne kelime kendinden geciyor desek daha dogru olur. Neyse evet, bunlari anlatmayacagim, aslinda sadece bir animdan bahsedecegim. Her aklima geldiginde icimi burkan bir animdan bahsedecegim.

Olay kisaca su sekilde. Sarp ile parka gittik. Sarp her tarafa kosturup duruyor ben de arkasindan onu takip ediyorum surekli. Hava biraz serin ama gunesli, montlarimiz var ustumuzde, aylardan Ekim veya Kasim olmasi lazim. O sirada parkin banklarinda oturan yaslica bir nine de bizi izliyor tebessum ederek. Oynadik kosturduk falan ben biraz yorulunca gittim, ninenin bulundugu bankin yanindaki banka kendimi attim. Sarp mi? O hala kosturuyor :)

Biraz bu sekilde uzaktan izledikten sonra, Sarp'a haydi gidiyoruz diye seslendim. Yasli nine, "evladim gidiyor musunuz?" dedi. Ve sonrasinda "Gitmeden sizden birsey rica edebilir miyim?" diye sordu. Tum diyalogu ve benim durumu kavrayana kadar gecen sureyi atliyorum. Ricasi su idi, evde televizyon kumandasinin yanlis yerlerine bastigi icin, tekrar istedigi kanallari acamadigini soyledi. Kendisine yardim edecek cocuklari da tatile gittikleri icin sabahtan beri parkta oturup birisinden yardim istemek icin bekledigini soyledi. Durumu tam olarak anladigimda icimde nasil bir seyin koptugunu anlatamam. Yardim ettim ama cok uzuldum, gunlerce aklima geldi. Ve hatta dedigim gibi ne zaman parka gitsem, icimde bir burukluk oluyor.

hepimiz yaslanacagiz

Simdi, kumandayi kullanmakta ne var diyeceksiniz ama iste olmayinca olmuyor malesef, biz de yaslandigimizda cikan teknolojiler sayesinde bu sekilde caresiz kalabiliriz. (Hatta ben yavas yavas bazi seyleri yerli yerine oturtamiyorum, mesela su snapchat garip, bir turlu kullanamiyorum arkadasim. Benim gibi dusunen bir cok yasli da varmis hatta :))

Ama iste bunun olmasini engelleyebiliriz. Benim nacizane iki onerim var (size degil, kendime :))
  • Esiniz, sevgiliniz, aileniz en yakin dostlariniz olabilir. Bunlarin disinda da her dakika gormek zorunda olmadiginiz dostlariniz da olmali. Bu konuyu daha once ele almistim tekrar tekrar yazmiyorum :)

Simdi bunlar isin bir tarafi...

Diger taraftan ise, siz siz olun anneninizi, babanizi, dedenizi, ninenizi bu durumda birakmayin. Her zaman savunmusumdur, Turk aile yapisi bir cok kulture gore cok daha dogru geliyor bana. Kucuklerin ailelerinin himayesinde olmasi, yaslilarin ise cocuklarinin guvencesinde olmasi asla vazgecmememiz gereken prensiplerimizden bence. Bu yaklasimin yeni nesil icin ozguven eksikligine neden olabileceginin farkindayim. Benim savundugum, ozguveni olusturmak icin farkli farkli yontemler varken, bu kadar ozel bir adetimizden vazgecmememiz gerektigi.

Ve evet bayramlarda tatil koyleri yerine aile ziyaretinin cok daha huzur verici, cok daha dinlendirici ve cok daha insani bir durum oldugunu dusunuyorum.