Tuesday, November 24, 2009

Game Development: Unity

About a month or so ago, I was thinking to myself: "It would be interesting to build my own first-person shooter, or first-person adventure game. It shouldn't be that hard. First-person-perspective games are all over the place. Surely there's an engine out there that would be easy for me to add my own content to."

My first web searches weren't promising. I found Ogre, which is open source, mature, and full featured, but appears to require some hard-core coding to use. I found the Dark Places engine, which I know has done some interesting things, but the documentation appears to be somewhat lacking. In short, I found a number of tools that might help develop a first-person game, but all of them required a fair amount of elbow grease on the part of the developer.

Then I ran across Unity. Unity is a game development kit -- not just an engine that you have to link your code to, but a full development kit, including a GUI for assembling game objects and for writing scripting logic. It allows you to quickly assemble common gaming paradigms (such as an FPS) by drag-and-dropping some template objects into your game. It's not limited to just first-person games, of course; you could produce just about any kind of game you wanted very easily. The first-person controls are a drop-in template, and if you want to produce a real-time-strategy game or something else, you just don't bother with the first-person template.

The scripting engine is also very powerful, by which I mean that it allows you to accomplish significant tasks with very little code. I'm scripting in JavaScript, but the tool also allows you to use C#, or a few other languages. Once you've tossed your 3D objects and your scripts into the tool, you just click the "Build" button and it will produce a standalone executable (for Windows or for Mac), or a package that you can embed in a web page like a Flash application. Alternate versions of the tool will also let you build games for the iPhone or the Wii.

And the basic version is free, for both personal and commercial use.

There's a pay version as well, which provides more features, some of which you would probably want if you were producing serious professional titles. But the free version, which I've been toying with for a few weeks now, has just about everything you would need to produce a pretty slick game with 3D graphics, and pretty quickly as well.

When I say "just about everything you would need", I'm coming to the caveat, which, personally, I have no problem with. If you want to produce 3D objects that are more complicated than just cubes, spheres, and planes, you need to build them using a 3D modeling tool. If you want textures that are more complicated than just uniform colors, you need a graphics drawing tool. Unity is a tool that lets you throw a bunch of parts together and build a smooth, good-looking game ... but you have to provide the parts.

Fortunately, Unity doesn't force you to use any specific external tools. I'm using Blender for modeling, and GIMP for textures. It makes for an interesting development model. I can focus on the visual design of the game, and the logic that produces meaningful game events, without having to worry about pointers or linked lists or encapsulation or API's or what not. Unity turns me into a game artist instead of a game programmer.

I think this is a good thing. Producing a good game is about much more than managing memory allocation or putting together build scripts. It's about providing a game that appeals to the senses and is fun to play. The whole "writing a bunch of code to manipulate a bunch of 3D objects on the screen" thing is a solved problem. This sort of thing has been coded over and over and over. You can make good stir-fry in your own kitchen without having learn how to brew your own soy sauce from scratch; why shouldn't you be able to build a game without having to learn C++ or DirectX?

The next question, at least as far as my own efforts are concerned, is: can I make a good game with Unity? Practically all of my game projects get abandoned at about the 50% complete point. Is it because I'm spending too much time on the code, and then get burned out on the project just as it starts to produce something playable?

I have a small demo game in mind that I'm working my way through; something relatively simple, but something that should require me to build all of the features and game assets that a proper game needs to function. If I can finish it, and it turns out halfway decent, I may try something more elaborate. In the meantime, I'm having fun, I'm learning cool things about Blender, and it hasn't cost me a dime yet.

I should also mention that the Unreal Development Kit is also out now, and is also free for noncommercial use, but if you want to sell your projects, you have to buy a license. Why am I using Unity instead of Unreal? Well, a quick look at both tools showed me that I'd be up and running quicker with Unity. The documentation and tutorials provide for Unity were clear and straightforward and demonstrated how quickly you could get something playable. Unreal is full of state-of-the-art features, but it looked a lot less newbie-friendly to me.

No comments:

Post a Comment