Sunday, December 15, 2013

Unity sanity check

The last several months have seen me subsequently looking for new work and then settling down into a new position.  As such, work on game development was slow to non existent.  I originally hoped to release Shattered Throne onto XBLIG this summer, but that window has obviously come and gone.

Also during that time, two key things happened.  The first was the release of the Xbox One and the exit of XBLIG Community Games.  I really wanted to get Shattered Throne submitted well before this happened, but alas, it just didn't work out.  As such, one of the primary reasons for working in XNA has expired.

Seeing this on the horizon a while back, I had been keeping a pulse on the Unity game engine, seeing it as a likely engine to use in my next project.  And it was in early November that the second key event took place, one I had been eagerly awaiting, Unity released its own build in 2D support.

So one event was a disappointment, the other exciting.  One small lesson I have learned in being a hobbyist game developer, is that you need to keep excited in order to keep moving forward.  So I gave in and played around with the new Unity release.  First following a nice pong tutorial, and the next jumping in and trying to puzzle out a tower defense game (which my son had designed on paper).

Feeling pretty good about Unity, what it could do, and how to use it, I gave myself a short quest, spend 2 weeks moving Shattered Throne to Unity, and see how far I could get.  It was the obvious question that had been in the back of my mind after all.  I was very nervous however, as Shattered Throne has been in my head for many years, and inevitably started and stopped on each new platform/engine that struck my fancy.  I was so close to release, had put my own money into art assets, I could not afford to start over.

But I could not let it go, so I gave myself two weeks.  Prove I could reuse a lot of what I had already written, or realize I would have to basically start over.

Things started out on the right foot.  I had been very good in keeping my presentation and game engine layer separate, and within 3 hours, I had the entire game engine data objects and gameplay engine moved over and compiling in Unity.  Nothing was hooked up to the display or player controls, but I had all the pathfinding, rewind, gamestate management, levels, unit and map data, combat calculations, game systems and AI sitting there, ready to be used.

Then I started work on the game play display.  In the simple act of putting the map display together, I realized that the new Unity 2D tools were not going to work out for me.  While Unity has a really good automatic sprite sheet splitter built in, there seems to be no way to switch sprite images within these multi-sprites from within code.  Such as when building a map from data loaded from disk....

Sure, it is possible to create a prefab for every terrain type, and then assemble a map from those, but this would end up being a large number of prefabs when all the water edge and corner transition overlays were counted.  Also I was likely to have the same issue with the Units themselves.

Some research led me to the 2D Toolkit.  Turns out it has been updated to work with the new built in 2D unity objects, and still provides additional value, such as Sprite Atlasing (automatically assembling individual images into a single texture to reduce draw calls), a built in Tilemap object, and ability to dynamically change sprite images in code.  I made the purchase, and have been very pleased with the results.  The author is extremely responsive on his forums, answering questions from users extremely quick.



So the two weeks are gone...what is the end result?

Things have worked out quite well.  The game is mostly playable, there are still some rough or missing animations and effects, but you can move and attack with the units.  Also a few button hookups away from Ending a turn and undoing actions.  I had planned on redoing all the ingame menus and screens (such as building units) anyways, so I will not be losing time redoing those elements, and they will likely come together quicker due to the built in support such elements have in Unity, as well as the NGUI toolkit, which I purchased when it was on sale for a song.




So for now, I will continue to work in Unity, at least for the near future.  I must say that there is some relief in not worrying about getting it finished before XBLIG completely evaporates.  Using Unity also opens up several additional platforms, such as Linux, Mac, iOS, and PS4 which I am all interested in.  Of course, the biggest hurdle on releasing to additional environments is testing, which is already a difficult task to undertake with just a PC release.



8 comments:

John said...

Since you're going this route, I saw this SVN add-on that you might find useful.
https://www.assetstore.unity3d.com/#/content/7242

Marte said...

Really nice!
I think unity2d could help you a lot, keep us informed about this path

Harvicus said...

@Marte will do. I was able to get quite a bit of work done this last week, and if all goes well, I hope to have the main gameplay screen finished by the end of next week, and will write up an update.

@John Looks like a cool addon, but I have everything setup right now with SVN with no complaints, but perhaps in a future project. Thanks for the link!

Pavel K said...
This comment has been removed by the author.
Pavel K said...
This comment has been removed by a blog administrator.
tahamina begum said...
This comment has been removed by a blog administrator.
Adrià Batlle said...

Hi Mark, I am currently developing a game similar to Shattered Throne and it would be awesome if you could send me some code/information about how you designed the models (Map, Units, movement, attack, etc).

It would help me a lot with my game development progress and I would really appreciate that.

Thanks and good luck with your games!

Harvicus said...

Thanks for the comment Adria, I have been meaning to do a post on exactly this for a long time now. Had lots of real life bits distract me from this project for the last several months, but I have started regaining my enthusiasm lately, and will try to put it together at last. Are you interested in the Unity specific implementation, or engine generic?

Wish you luck with your project, and hope I may get something of some interest up here in the next week or two. Thanks for stopping by.