Game Development Software: Unity Free

I’ve decided to do more in-depth reviews of the software I use. I’ll start by detailing the various features in one of my favourite pieces of software I’ve used so far, Unity 4 Free.

unity-logo

What is Unity?

I’d be surprised if you haven’t heard of this already – just a quick Google search for “free game engine” will return it as the top result. Unity is a 3D game engine that’s designed to speed up and streamline the development process, while providing all the powerful features you’ll find in similar products. While some features are restricted to Pro (such as realtime lighting and post-processing effects, I’ll be talking about these later), the free package contains most of the features you’ll need. So don’t be put off by the fact that a Pro licence costs $1500 in one payment or $75 a month, just go download the free version to see if you like it.

The Unity Editor

unity-editor

The Unity editor, your window to making the games of your dreams.

The editor itself was designed with customisation and workflow in mind. You can see a load of windows in this screenshot, each of which can be freely docked on any side of the screen, or even pulled into a separate window if need be. Each window has a specific function:

-On the left is the hierarchy pane, which lists all the GameObjects (this is what Unity calls any old object you lob into the level, which are called scenes). GameObjects can be stacked (or ‘parented’) onto other GameObjects, in a hierarchical manner, hence the name of this window.

-On the right is the Inspector view, which frees up all of the variables and components attached to the active GameObject so they can be changed easily without having to delve into the source code and change variables directly.

-On the bottom is the Project pane, which lists all the assets available for your game, which can be dragged and dropped straight into the level.

-Most importantly, in the centre is the Scene view, where all the action happens – this is where you’ll be moving around all the GameObjects in the scene to build up your level. Here you can see the currently selected object, my player, and the gizmos that represent some of the components on the player, for example the blue sphere is an audio component, and the white cone is the main camera’s field of view. Once you’ve finished building the level the way you want, you’ll want to test the level –  in Unity, this is a breeze, as all you have to do is click the play button at the top-middle of the screen, no waiting screens, no lengthy compiling required, just an instant transition from the Scene view to Game view, where you’ll play the game as if it were a proper build of your game.

Scripting with Unity

Unity provides the functionality to program with your choice of three programming languages, C#, Javascript and Boo, and a script in one of these languages can communicate seamlessly with a script written in either of the other two. A plethora of classes are available for manipulation from the start, giving you complete control over any GameObject and all the components attached to it, the physics engine, the inputs used in your game, everything. Unity provides comprehensive documentation on all aspects of scripting with Unity, just take a look at the Unity manual and look at all the classes along the left-hand side to see just how much of the engine is under your control. And if you’re completely stumped at how to start programming with Unity, there’s a whole playlist of tutorials on Unity’s official YouTube channel, plus Unity provides Live Training on its website every so often, the archive of which can be found on their YouTube page too. Unity ships with MonoDevelop, an IDE (Integrated Development Environment), which is very handy as it’ll error-check and auto-fill everything that’s specific to development with Unity. Also, it’s important to note that the Javascript used in Unity is a slightly modified version called Unityscript, although it functions much the same as conventional Javascript.

unity-mono-develop

This is MonoDevelop, the IDE that’s provided with Unity.

If you don’t like MonoDevelop, or just prefer another IDE, then you can set another default program by going to Edit->Preferences->External Tools, then change the external scripting editor by browsing for its location on your computer.

The Asset Store

Having trouble modelling a character? Need a few more ambient sounds for a dark alley in your level? Completely stuck and need a completed level to use as a starting point? Then someone’s bound to have done it already on the Asset Store, an online marketplace foe everything you’ll ever need in Unity. From editor extensions to particle effects, models, animations, textures and even complete projects available on the store, you’ll be hard-pressed to find something that’s not on here.

unity-asset-store

The Asset Store will be your go-to place if you’re looking for something to use with Unity.

There’s plenty of stuff that’s completely free, plus there’s occasional sales, giving you a lot for a reasonable price. If you’re going to be developing with Unity, then a good free package to start with is the Sample Assets package provided by Unity Technologies themselves, which gives you a fully rigged and animated character controller called Ethan, multiple vehicles, and many other assets to help you out at the start.

In-game lighting and lightmapping with Beast

Unity has built-in support for the Beast lightmapper, a powerful tool that will bake static shadows onto your level, cutting down on the realtime impact of calculating shadows every frame. You can set how detailed and how strong the shadows are, which lights will be casting shadows and which objects will receive these static shadows, then click bake and Beast will automatically create very detailed lightmaps for you in a relatively speedy process. Back in the editor, there are four different types of light – point lights are like light bulbs and provide light emanating from a point in space which falls off with distance, directional lights act like the Sun and provide uniform light in one direction across the whole level, spotlights are self-explanatory and provide a cone of light from a point which falls off with distance like the point light, and area lights which are Pro-only, so I have no idea how they work. One massive drawback to Unity Free is the lack of realtime shadows – only one directional light is allowed to produce realtime shadows in Free, but no point lights or spotlights will cast realtime shadows, a truly disappointing omission, but not one that’s so huge as to prevent you making a good game with Unity Free.

unity-lightmapping

This is the sort of result you’ll get after creating lightmaps. These are the plastered on top of your game geometry to simulate lighting.

Nvidia’s PhysX Physics Engine

Unity uses the PhysX physics engine developed by Nvidia. It’s a very comprehensively constructed engine, handling collisions between objects, applying forces and gravity to them, and moving objects realistically due to the acceleration produced by these forces, all while allowing complete realtime modification through scripting. I use this functionality a lot while developing with Unity, so having so many functions available is helpful. Not only can forces be applied to objects in one direction, but explosion forces can be applied from a point in space to all nearby rigidbodies (physics-affected objects have a Rigidbody component applied), object’s masses or drag can be modified directly to affect motion, and collisions can be used to initiate events in-game. The physics engine supports the use of joints too, such as hinges or springs, and it works in both 2D and 3D, with dedicated components and functions available for both.

unity-physics-explosions

Explosions, just one of the effects you can achieve with the physics engine. And yes, this is my game, which you should be following by now.

Shuriken Particle Systems

Particles are important for applying a final touch to a game. Whether the particle effects are just debris from a gunshot or something much larger like a collapsing bridge, they add a lot to any game. Unity uses its own particle system, Shuriken, to handle particle effects. This is completely customisable as with everything else in Unity, allowing you to modify the speed, direction, rotation and size of individual particles, and change these over time too. Then you can change the force applied over time, the colour, transparency and lifetime too, as well as the particle texture which can be a spritesheet as opposed to a single texture, allowing a lot of room for creating the effect you desire. The particle themselves can simply be billboard textures, so they always face the camera, or a mesh, so physical 3D objects are emitted by the system, and they can even handle collisions, with different levels of quality to preserve performance if needed and the option for collision callback messages to be sent to scripts, so you can make events occur when a particle hits a surface. If you don’t have the time or resources for this, there’s plenty of particle systems on the Asset Store.

unity-shuriken

These are some of the many variables you can choose from when making a particle system. The grey bars can be expanded to give even more variables and many can be disabled if not needed.

Terrains

Unity also has a terrain generation feature. A terrain is simply a large mesh that will make up the majority of the ground of your level, with a terrain collider attached to it and the ability to add multiple textures to the surface to represent realistic ground. To create a terrain, you can go to GameObject->Create other->Terrain, then you’ll need to select its size and height. If you select something a little too big then that’s not a problem, you’ll just have to improvise and construct your world so some areas are blocked off, but make sure it’s not too small or you’ll have problems, because it’s a bad idea to resize a terrain you’ve already shaped and textured (something I’ve found out the hard way multiple times in the past). Initially, you can carve out the shape of your terrain using the raise, lower and smooth terrain brushes, which have options for the opacity and size of the brush, then you can paint the terrain with multiple, blend-able textures. It’s an easy-to-use but powerful feature, and is highly optimised so it should even work well for mobile projects. You then have the ability to add static meshes to the environment, such as trees, rocks or grass, which will be ‘batched together’ for increased performance. If that wasn’t enough, Unity has a very detailed tree editor, allowing for the randomisation of trees so a variety of shapes and sizes will be distributed across the environment.

unity-terrain

This terrain is from an old, abandoned project of mine. The trees are very slightly different from one another to mimic natural deviations in tree shapes and sizes.

Speed of development

Unity really shines when it comes down to speed. The instant playtesting feature is so useful when you’re prototyping and squashing bugs, or when you’re trying to find the best amount for, say, an enemy’s attack stat – just tweak the variable in the editor using the Inspector view, instantly play the game, then tweak it a bit more, even while the game is still running, so you can see the result straight away. Unity also has a genius Prefab system, whereby you can create one item for your game with a load of components and variables associated with it, or even child objects too, then you can turn this item into a prefab, which can then be dragged and dropped into the game as a perfect copy of the first item. Plus any changes to the source prefab will then affect any GameObject that’s associated with it, so it saves having to edit tens or hundreds of individual objects in your scene. This makes creating your game world easy and efficient.

Exporting to many platforms, plus your toaster

Unity supports publishing to so many platforms with little to no tweaks needed to your code it’s ridiculous – the same project cam be published to, hold your breath – PC, Mac, Linux, iOS, Android, Windows Phone 8, Blackberry 10, all major web browsers, and even Xbox 360, all recent PlayStation consoles and both Wii and Wii U. Of course, the consoles require licences from the respective companies, and publishing to iOS requires an add-on (which costs $1500, but a hit game on iOS is well worth the initial cost), but this is still a massive array of publishing options. The Unity Web Player itself is a fantastic platform, as you can deliver your game on all major web browsers with a few clicks, while the game itself will be so highly compressed that the user won’t need to download gigabytes of data to play it, allowing for instantaneous streaming of your game. The number of available platforms grows over time too, so you’ll never be short of a prospective audience.

unity-multiplatform

All. These. Platforms.

What’s missing in Unity Free?

A few major features are missing from Free but present in Pro. Firstly, as mentioned before, there’s only one realtime shadow in Free from one directional light, but in Pro you can have as many realtime shadows as you want, which can sometimes be the difference between an alright game and a fully immersive experience. Plus Pro gives you area lights, but I still have no idea what they are. Pro also utilises occlusion culling to increase performance, whereby objects that are obscured by another won’t be rendered at all. This isn’t to be confused with ambient occlusion. Think of a wall, with a small cube behind it. In both versions of Unity, the back face of the cube and wall, and perhaps some side faces depending on what angle you’re looking at them from, won’t be rendered as they’re facing the other way, but with Pro’s occlusion culling, the cube won’t be rendered at all because it’s obscured (or, occluded) by the wall. This saves your GPU lots of work with minimal CPU overhead.

Pro also gives you the ‘render to texture’ feature, which allows you to take a camera’s view and make it into a texture for use in, say, a TV screen, or to take screenshots. It can also be used for mirrors, or reflective water surfaces, so it’s a very powerful feature when put to good use. Pro also has a profiler bundles with it, which shows you where resources are being used in your game, for the detection of bottlenecks. It’s a helpful tool for increasing the performance of your game.

While Unity Free has a pathfinding tool built-in, Pro expands upon it massively, allowing more control over where characters using the pathfinder can move, and how they transition from area to area.

Another large feature missing from Free is post-processing effects. The ability to take a frame then add effects such as anti-aliasing, glow, bloom, motion blur and colour correction enhances your game graphically. This sort of feature is present in the free versions of other game engines, so it’s a feature I’d like to see in Unity Free. Also, games published with Unity Pro don’t have the Unity watermark when started up.

Summary

Unity Free is a very powerful, giving you a feature-set that will allow you to make very complex games. The sheer amount of help online from Unity is astounding, plus the comprehensive Unity manual, which can be viewed offline, explains every part of Unity very clearly. The community is extremely helpful too, with forums accessible for those with questions on any part of Unity, and for people to show off their work, completed or in-progress. The speed of development of games with Unity is above that of most other engines, and the sheer number of platforms you can export to means that your possible audience is as big as possible. There are many built-in features provided to aid you in making all genres of game, such as terrains, particles, physics, lighting and lightmapping, and even pathfinding. With Unity 5 just around the corner, now is an exciting time to be a game developer with Unity. However, the free version suffers from some missing features, such as realtime shadows, post-processing effects, the profiler tool and render-to-texture, some of which are found for free in similar game engines such as Unreal Development Kit or Source. If you’re an indie developer and you’re looking for a fast but powerful tool to fuel your game, then this is a brilliant place to start. Unity is a game engine you won’t regret downloading.

If you have any opinions on Unity, then I’d quite like to hear them. Maybe you also have some other great engines you’ve used that you’d like to suggest to people starting out with game development too? I hope you’ve had fun reading, and have fun with Unity if you choose to have a go at it!

27/04/13 Update

Okay, I was wrong, I’ve had a while today to sort out more game stuff. There’s more options in the options menu, and I’ve worked on the game GUI, as well as other small things. As always you can check out the game by downloading it. Here are the changes:

unity_platformer_8

There’s not much of a change here, but I remembered the floor is just ordinary terrain but it was boring and flat, so it deserved some kind of hills, to make it interesting. Its just little details like that which will make the final game just that little bit better.

unity_platformer_9

Everything now has neat little boxes round them, I like how it looks. There’s a volume slider, which will change your volume from 0-100%, it’s pretty neat. However, since the game has no sounds currently, I don’t even know if it works or not, it should do though. The terrain is again altered to have some bumps, and it looks quite desert-y now, which is what I was going for. I could add some kind of sandstorm effect just to make it even better.

unity_platformer_10

The part I’m most proud of with this update is the gem counter. It’s integral to the gameplay, and I’ve got it working flawlessly. Each gem is worth a certain amount- quartzes are worth one gem, emeralds two, onyxes 3, sapphires 4, rubies 5- and the game counts this and shows it in the corner of the screen. Another nice thing about this is that the portal in each level now requires a certain number of gems to unlock, currently this is 20 gems. If you try to jump through the portal with less than the required number of gems, you’ll just fly through it. I will add some text to show the name of the level and the number of required gems (if applicable) in front of/above/near portals in the future to help players.

The next step is to add more collectibles, and some kind of container for collectibles. More collectibles, such as additional gems, could be a good idea, but a rarer collectible is what I really want to add. They will be fewer and further between, and harder to find than regular gems. Some ideas I have at the moment are diamonds (they could be quite large and sparkly to distinguish them from regular gems), gold bars, a kind of magical item, ideas like that. I’ll think of more then decide on one later. The containers will probably be in the form of crates, jars, destructible scenery etc, and when you break them open gems will fly out around you.

Another change will be the collision of the gems- I realised they float slightly above the ground so I’ll just raise the collision box of some of them. I will also add some animations for the gems so they rotate on the ground and sparkle occasionally, and so they disappear in a flurry of sparkles instead of spontaneously disappearing.

I also need to add scenery to the levels, in the form of buildings, boxes, bridges, roads, trees and other things to make the game more lifelike. This may take a while, and I want to concentrate on getting the game to work first, the decoration could come afterwards. I would like to add newer terrain textures too, not just the Unity defaults, so I will work on that.

As always, just leave a comment if you have any ideas, and thanks for the support.

-Daniel

25/04/13 Update

Sorry I’ve been away for a while guys, I’ve been very busy with school work, and unfortunately that means I’ve been unable to get much done in the way of game development. This does mean I’m not doing the April Challenge I set out to do as such, however development on my game will continue until it’s completed and I feel that people will be satisfied with the final product. I may not be able to update the game very much in the next few weeks, as I have rapidly approaching AS modules, and I need time to work on revision for them, but I will do what I can, and the game should be officially released at some point in the future, maybe next year depending on how fast progress is. I have tried to add an options menu into the game, and it works how I want so far, albeit lacking features, which I will add later on. unity_platformer_7

 

Again, the player can be moved along with the WASD keys, as a little bonus feature. The current features on this screen are buttons to increase and decrease the graphics setting from Fastest to Fantastic, which is very noticeable on the terrain texture as you go from low to high quality, and our current graphics setting is shown below that. There are also a few computer specifications in the corner, just to give the player a little information about their computer. There’s also a button to return to the main menu, as this screen is accessed through a new button on the start screen. Yay. A really bad FPS counter is also at the bottom- I say it’s bad because it’s very very wrong, so you may as well ignore its existence. That’s all I have to show at the moment on my game, I will have more time later on to update it, so keep reading and come back often to see my progress. The download for the game has also been updated, as ever you can check it out here. Thanks for reading.

-Daniel

Day 13 Progress

This is the download link to the latest version of the game:

https://www.dropbox.com/sh/0o38di2thg3x9za/N_CvcxejXT

I’ve been working on making new terrain for the levels in my game. The levels are a bit basic at the moment, and they don’t have many features, but they are much more interesting than what I had before. I have been experimenting with heightmaps and the Unity terrain generation to get better level terrain, and I am happy with the result. I had a few problems initially because using heightmaps in Unity requires .raw files, which are basically image files with very little formatting, and I am using GIMP, which cannot save to a .raw file. I found a program that can convert png files into raw files though, so I got it working eventually. Here’s a tip: if you have Photoshop, use that, it’s as easy as just saving to a .raw file…  hub_world_1

This is the heightmap I used for my hub world. I got this through a quick Google image search but you may want to create your own, like I did for my other levels.

A heightmap is basically a top-down greyscale view of your terrain, with white areas highest up and black areas lowest down, and grey in-between. When this is imported into Unity using the Terrain feature, it automatically creates terrain to match your heightmap. That makes it much easier to create your levels. You can then ‘paint’ your terrain with any texture you want, and bam! You have your basic level. Then you can just add objects in, like scenery, enemies and collectibles, and you have a game. I need to add some enemies and scenery, but I’m happy with my current progress.

I have also been working on getting my character to pick up gems, and it finally works! There is no counter to actually keep track of how many you’ve picked up and they have no function yet, but this will be implemented soon. The way I fixed it is by adding the ‘Rigidbody’ component to the box collider my gem pickup script was attached to, as this allows the ‘OnTriggerEnter’ function in the script to work. Basically this function is activated when any object with a collider component enters the collider of the object I’ve attached the script to, in this case the player. When activated, the script checks for any objects with a “Gem” tag, and destroys it from the game completely. So now you can pick up gems. Yay!

unity_platformer_3

This is the GameObject that handles all the gem grabbing.

I have also made a very simple start screen with two buttons, one to enter the game and another to quit the game. This is made with Unity’s built-in GUI creator. In this title screen, you can also walk around with the player, a feature I want to keep in the final version. It looks like this: unity_platformer_4

When you press the “Quit Game” button, the application will simply close. But when you click the “New Game” button, it will enter the game, starting with the hub world. This has had a few minor changes too: unity_platformer_5

The terrain for this world was made with the heightmap above, and it made a level with a couple interesting mountains as well as a large flat land in the middle. The textures are just default textures provided with Unity, but I will change them to something I like a bit more at a later date. I’ve also added a skybox, which is basically an imitation of a sky, but the camera angle doesn’t let you see it very well. There is a portal in this world leading to “Level 1”: unity_platformer_6

This is supposed to be a desert-like level, but I haven’t had much time to work on it so the textures aren’t complete. The heightmap for this one was entirely made by me though. I’m very happy with the progress I’ve made here, and I hope you will all have fun playing around with this, and if you find any problems or anything you would like added, please don’t hesitate to comment below. Thanks for all the support.

-Daniel