Working with Unity 3D
My master studies began last october with several computer science lectures like artificial intelligence or virtual reality, furthermore I took part in a poject-centered seminar. The topic was closely related to the virtual reality lecture – we created a game that depends on the mining tradition of our city and we used the game engine Unity by Unity Technologies, which is often simply called Unity-3D. The main topic was to explore the function (and maybe discover the limitations) of Unity and try to focus on immersiveness and good performance.
My main motivation was to see how it feels to work with a „real game engine“. During my bachelor studies I made first experiences with creating games in a working group. Instead of using a game engine we decided to do „all by ourselves“, moreover the limits and conditions of several game engines like OGRE were a bit troublesome at this time. About 2 or 3 years ago things were of course different compairing to today. We decided to use OpenSceneGraph as a main framework, Bullet as our physics engine and Blender to create the 3D-models. Due to less experience with OpenSceneGraph some friends and I, we started with other tasks and learned about OSG alongside. At this time I started with modeling and later I was programming HUDs e.g.
It really was interesting and fun but sometimes a little bit hard. To search for missing informations in huge documentations was a bit troublesome. Because of all the free frameworks the amount of tutorials and websites that offers help were really meagre compairing to other software. The result was working and we were really proud of it (Well I only know that I was :)) but it still hasn’t the look and feel of modern games and many of our strategies were not really state-of-the-art – I learned about lately but didn’t know years ago. Reviewing I would say that the use of alle these free frameworks that were everything but not a game-engine made our work too cumbersome to implement all these state-of-the-art methods. Nevertheless the time was really fun and it was one of my best decisions to take part and I’m really thankful for the experiences I made. Concluding I have to say that I learned a lot, but I was curious to see how it would be to work with a game engine.
What is Unity 3D?
Unity 3D is a developing environment for 3D video games which includes visual editing and allows you to preview your game and make a full walkthrough. For this purpose it comes with it’s own game engine, a well arranged community and lots of documentations and tutorials. Furthermore it offers an amount of ressources you are free to use. The designed game can be rendered as an executive. The game-play can be managed through source code and attached to the game-scene.
The user has two options to decide between: Unity and Unity Pro, which differ in the available functions. (See below, paragraph Disadvantages?) Supported platforms are Windows and Mac and I recently read that Linux is planned(?).
This article features Unity 3.5.0 (free version) and was tested on Windows.
Graphical User Interface
Unitys Interface contains nearly all often-used basic gadgets and displays the most important information. The graphical user interface (GUI) can be divided into the areas Hierarchy, Project and Inspector.
These areas plus a menu bar, status bar and a tool bar (under menu bar) surround the current scene. By changing between the tabs Scene and Game you can choose between editing or testing. In scene-mode you are able to manipulate the project, while in game-mode you can do a walktrough and display the current result: your game so far. While in scene-mode you can simply drag and drop as you like: clicking on the object and directly manipulating it.
The Hierarchy-area (left in the picture) shows all the object that were imported into the scene. When clicking on of the object names, its properties are shown in the Inspector (yellow highlighted in the picture below). The same happens if you directly select the object from the scene-window.
It depends on the object what properties you will see. The screenshot shows a selected light source and you are able to do some settings and changes in the Inspector, e.g. editing the light sources strength.
In your scene can be different objects: 3D-models, terrains, light sources and much more. Every private folder that contains e.g. 3D-models can be added to the project and then appears in the Project-list (highlighted orange). Unity itself offers a huge amount of so-called Packages or Assets which allows you to use free ressources like Trees, First-Person-Controller or special effects – just mentioning a few. All these assets can be selected when starting a new project or through the menu bar. In every case you see all imported objects or set of objects in the Project-subwindow as well as the Hierarchy-subwindow. The difference is that you see in Project which ressources are available while you see in Hierarchy which ressources are already in your scene.
Tools for grabbing the scene, moving objects, rotating them or scaling can be found in the toolbar under the menu bar. The play and pause buttons are another way to start or stop the game you created so far.
All other aspects can be handled through the menu bar: setting up physics, creating a terrain or customizing your Unity 3D-Window.
What I described is of course the default GUI. You can change the look and switch between gadgets to customize your GUI.
This partitioning makes it easy (and fast!) to use Unity 3D. For some of the hardcore-programming-geeks it maybe looks like model kit for rookies but the working rhythm is very comfortable and easy to control. The programming part follows and can be handled like you wish to.
How To Set Up A Scene
A lot of tutorials are available through our beloved WWW but I give you a short outlook on the rudimental steps, so you can see which aspects are no difficulties while working with Unity.
- set up the project (File->New Project; File->New Scene; import standard assets or just all assets if you are brave)
- create a terrain (Terrain->Create Terrain)
- create a skysphere/-box (optional; Component->Rendering->Skybox)
- set up any lightsource (if you went through the point with the skysphere, a directional light imitating the sun would be nice; GameObject->Create Other->…)
- set up a first-person-controller with camera (search for „First Person…“ in Project-Subwindow and drag and drop the Controller in the scene)
Every cumbersome part like the difficulties of a first-person-controller and the question how to navigate through the game are managed. Now you are able to concentrate on what you wanted to program and how your game has to look instead of puzzling over „how to walk“. Tasks like a third-person-controller can be done later.
Nearly every needed function is hidden in
- the inspector
- the menu bar
Settings concerning ressources are always available through the Insepctor as already mentioned. After selecting a object in the scene, the hierarchy- or project-subwindow you can edit it’s properties in the inspector. This includes e.g. changing the color of an object, adding details to a terrain, creating a bump-map or normal-map (select the texture!) and much more.
Other functions are available through the menue bar. It contains following self-explanatory points (f.l.t.r.):
- File – usual managing tasks
- Edit – usual tasks like undo, redo; some advanced networking-methods
- Assets – importing and exporting assets and packages which contain ressources e.g. importing 3d-models your prepared on your own or importing downloaded assets or exporting compositions or 3d-objects and lightsources
- GameObject – creating simple objects like spheres or cubes as well as GUI Textboxes
- Component – advanced functions like physics e.g. adding a collider to objects so you cannot walk through them
- Terrain – options for creating a terrain
- Window – customizing options
- Help – documentations
Every changes can be made undone and the GUI is very intuitive – you’ll learn very fast how to work with Unity just by doing. And every problem can be solved easily via looking it up on the unity community.
Let’s talk about the really interesting part – which options offers Unity for programming tasks.
The surprising fact is that Unity 3D is not bothering you with restrictions like not available functions. I expected something like this and was really pleased to see that Unity 3D comes with a nearly full implemented library, even if you are working with the free version of Unity 3D. Some not available aspects are lighting effects like advanced shadowing options or effects like fog.
So the amount of aspects you can directly program is huge. From collision detection, creating objects, physical options, trigger zones and customized GUI texts (dialogue boxes) nearly everything is possible. And even if you say „where is the fun when I don’t have to program collision detection on my own“ nothing prevents you from programming your own methods. You can directly use objects propertiess by the objects name. The possibilities are endless.
Of course the long description above contained lots of advantages but there are some drawbacks we have to cope with.
I only said good things about the intuitive man-machine-interface but not everything works fine.
Pay attention to differ between project and scene.
The project includes imported packages/assets and the scene itself. It’s the visible part.
The scene is the arrangement of objects, terrain, light sources etc.
A bit cumbersome is that yo have to save the scene AND the project. Only saving the project and closing it results in loosing all the changes you made on the scene. All this happens without a warning pop-up. So be attentive. I saw experienced programmers loosing the work of hours! (and yes…we were mocking people that forget to save but it’s really another issue if you have to remember saving TWICE. 😉 )
If you are not willing to purchase Unity Pro you cannot use Deferred Shading. So you have lighting and shading but: no shadows. Which is really a drawback. You can handle this disadvantage through making use of a clever way of positioning and setting up your lightsources and using bump-maps to make the scene look more lively. That’s what I did. Another possibility is to use shadow maps you created on your own. Maybe a very time-consuming task but it will be worth it.
Other functions that are only guaranteed by using Unity Pro is the use of C++ modules as well as creating a customized splash screen. (So when starting the game you created with Unity you will always have the Unity Logo at the loading screen.) When you ask me, the aspect of having no shadows is more bitter.
For last semesters seminar I worked several months with Unity and really enjoyed it. As already mentioned I had a taste of it before what it means to create a first-person-controller or camera view before and it’s not that easy, that’s true. Unity makes a lot of the real work for you – not every traditionalist out there would be pleased to work with Unity. But in my opinion Unity offers you the ideal working environment, because you can concentrate on the gameplay and your programming task. There is enough to do even of you don’t have to care about a first-person-controller.
Remember that in modern games you have to cope with questions of game logic or artificial intelligence – so would not run out of tasks. For sure.
The most significant drawback is that you cannot render shadows when using the free Unity 3D. At any rate Unity offers you to use bumpmapping, environment mapping, reflection mapping, parallax mapping and shadow mapping. Just mentioned a few. These advanced techniques are not the newest but imagine that: at the moment they’re not included in every other development environment. But in Unity.
So in my opinion: thumbs up for Unity!