Getting Started In Unity – A Rookie’s Guide

Like many of my game development peers, I come from a Flash background. Over ten years of experience, in fact. In hindsight, I think it’s actually far too long to be using the one development tool exclusively – especially when the rug is pulled out from under you by a self-serving prat.  In truth, I kind of shot myself in the foot by not exposing myself to other languages until this year.  If you put all your eggs in the one basket, you may just find that the demand for those eggs isn’t what it once was.

The good news is that if you find yourself in a situation like my own, all is not lost. Far from it in fact. Your skills are highly transferable. All that game design knowledge and experience doesn’t just vanish. If you can code in an object oriented language like ActionScript or Objective C, you’re going to find the transition to other similar languages is actually surprisingly smooth. You have to re-order your syntax slightly, add a semicolon here or there, but you’re not going from French to Japanese; more like from British English to American English.

thePatriot

 

As I’ve talked about several times this year, I’ve thrown myself into learning Unity, and by association, C#. I think Unity is awesome, I’ve seen games built in it that just blow me away and I think the demand for Unity devs is growing exponentially. It’s a collaborative IDE that allows programmers to build systems with relative ease and allows designers to create worlds using them. It’s by far the most collaborative game building tool I’ve ever seen. However, if you’re like me, you might find yourself a little bit unsure of just how to get started in it.

I’d like to share some thoughts, observations and provide links to some helpful tutorials that might prove of use to you.

The first thing I’d suggest to anyone just getting started with Unity? Download Unity 4.6 Beta. This probably goes contrary to what many developers would tell you, but the way I see it – you’re not going to be releasing any games right away. Unity 4.6 has one very important update to it, the way you design your User Interface stuff has been totally overhauled. This is a huge thing. In the past, GUI was a real battle to build, which is pretty surprising given how integral to games it is. I estimate you spend at least a third of your game development time just building your UI. Check out this video to see how the new UI will work – in a nutshell it’ll make responsive design for your interfaces much, much easier. It means you don’t have to learn things the old way or use a 3rd party plugin like NGUI.

Once you’ve downloaded the beta and got it installed, you should watch the series of Unity videos dealing with the Editor. Things like getting around the IDE, navigating the camera, adding lights and so on.

It’s worth familiarising yourself with the basic keyboard shortcuts for the editor because this will save you a lot of time down the track. It’ll probably feel pretty overwhelming at first, so many little panels, buttons to press and unfamiliar components. Unity gives you more than enough  rope to hang yourself with, but at this stage, don’t stress too much. For now, you need to understand the basic concepts of Unity, to familiarise yourself with terms like prefabsrigidBodies and components. There are going to be a lot of unfamiliar terms you’ll encounter as you go along , raycasts, navMeshes, triggers- remember you don’t have to know what they do just yet. You’ll be able to explore each one in time. Just like playing the guitar, you learn your basic chords before you shred your solos.

confusedKid

 

I think the most important thing I’ve learnt is this; you have to crawl before you can walk, and walk before you can run. It’s very tempting to see Unity and think of all the wildly ambitious games you’d like to make using it. Now you can potentially make 3D games, you’ll probably want to make a Minecraft clone or your own Mario Kart style racer – but you need to slow down. It’s not going to happen right away. Start small, very small. Take it in tiny pieces; learn and practice basic concepts before you start your masterpiece, because you’re going to get into trouble if you haven’t structured your game properly.

Some little things you might want to master first:

  • Create a cube. Turn it into a prefab. Try moving it around the stage, or scaling it using a keyboard shortcut. Add a material to it.
  • Add a rigidBody and a BoxCollider to it. Try and have it bounce off the ground. Play around with some basic physics.
  • Drag and drop a few basic scripts onto your cube; maybe a character controller to move it around your world.
  • Create a particle effect. Play around with the values, try making smoke or fire.
  • Move the camera around the stage, zoom in and zoom out. Press play, stop and pause. See how it affects the objects in your game world.

These are all just interesting little things you can try when you first start, none of them require any coding and they allow you to get your head around the Editor before you dive any deeper. You don’t have to settle upon what game you want to make at this stage, because you’re going to be restarting new projects numerous times before you finally settle on one. If you’ve got any old games made in another language or IDE, try grabbing the graphics and sounds from those and dragging them across to your Assets folder in Unity. See how it imports them into Unity, ready for you to play with straight away? How cool is that! You might even decide you want to port your game over to Unity as an experiment; given it’s a known quantity, you’ll probably find there are less surprises than building something from scratch. Again, a word of caution: start small.

Next up, the most important step (depending on your background) – learning to program. Unity offers JavaScript and C# as options for you to script in. While JavaScript is fine, I would dive straight into C# because it way more structured and will teach you to become a real programmer instead of allowing you to develop awful habits like JavaScript often does. As an aside, I came from an ActionScript 1 and 2 background (similar languages to JavaScript, really forgiving languages that allowed you to make mistakes) … when I started developing in ActionScript 3 I found it a real battle because I hadn’t learnt common coding practices like public, private variables, class scope, inheritance and so on. It took me ages to unlearn all of my bad habits. So, if you learn C# from the beginning, you’re not going to run into those same problems.

A lot of people I’ve talked to highly recommend you use Visual Studio for coding in Unity instead of MonoDevelop ( Unity’s default code editor) . It has much better code completion and refactoring and a whole bunch of advanced features. It’s also pretty expensive. You can get a free version of Visual Studio Express which works with Unity after a bit of tweaking , but personally I’ve had some teething problems with it. Every time I open a new C# script from Unity, it seems to open a new instance of Visual Studio Express – there doesn’t seem to be a fix for this that I’m aware of. So for now, I’m staying with MonoDevelop – if you’re on a Mac, you don’t have an option.

 

learningCSharp

And one of the best ways to learn C# for Unity, in my humble opinion? Get a hold of this eBook. It’s called Learning C# by Developing Games with Unity 3D and it’s written by a tremendous fellow called Terry Norton. I only found this book last night and I’ve read two thirds of it already. In all the material I’ve read on Unity so far, nothing comes close to this for just explaining basic code concepts like loops, variables, lists and dictionaries. I’ve been hacking stuff together programming for a decade and I still didn’t have my head around interfaces until last night ( actually pretty simple in concept, but nobody could explain them properly to me; who knew they were so simple and so useful?! ) . I can’t stress this enough, by the end of this book you’ll have all the C# knowledge you need to get started coding in Unity. It’s an entertaining read too, quite irreverent and informal. (One caveat, it’s slightly out of date – many programming books are, due to how fast Unity is updated – so if some of the code you type in doesn’t work, you may need to search Google instead.)

The other great reference I can recommend is the website of longtime ActionScript/Flash guru Jackson Dunstan, who has recently made the switch to Unity for reasons detailed here. If you’ve come from an ActionScript background yourself, this is a terrific guide to migrating over and one well worth bookmarking. Click here to get started with his AS3 to C# guides.

Once you’ve got your head around programming concepts in Unity, you’ll probably want to do a search for some good tutorials to follow along. Of the ones I’ve done so far, they’ve been a mixed bag. It’s personal preference, you may like the author’s code style or mannerisms, or you may not. I’ll run through a few with you now:

Creating 2D Games In Unity 4.5, by Nelson LaQuet and Steve Curtis from 3DBuzz


This is a very thorough and intensive series, some 38 parts. It starts off quite nicely with a good introduction to Unity, but there’s a lot of dead air and (to my mind) timewasting. The main programmer types very fast and it can be extremely difficult to keep up with him, you find yourself missing tiny but crucial steps because you looked away for a second. Worst of all, the 3DBuzz philosophy is to not include code scripts to download – their philosophy is that following along is the best way to learn; and while I can agree with this on principle, it can be incredibly frustrating to sift through hour long tutorials trying to find a step you missed, or to correct a typo. At the end of the tutorial you’ll have yourself a pretty robust platform game (here’s my attempt so far, incomplete – use the W, A, S, D and SPACE keys to control )  , but I’d caution against following this one too closely right away. In my mind he uses techniques that are way too advanced for beginner or even intermediate coders; things like using bitwise operators to determine projectile bullet layers and some pretty advanced maths for some things that could have been done a lot easier.

 

Creating a 2D Game with Unity, by the good folks at Pixelnest.io 

pixelNestGame

This is a web tutorial series which you can view here . You learn to make a 2D shoot-em-up by following along each page. Code snippets are included for you to copy and paste, and are thoroughly explained line by line. It gives you a great overview on many basic concepts for game development, including movement, collision, shooting bullets, adding sounds, particles and menus. By the end of it you will have built a ( admittedly rough ) shmup in the style of arcade classic RType. It’s not really optimised, so you’ll have to do a fair bit of work getting it to run smoothly on mobile, but these are techniques you will learn as you go. I really recommend this tutorial as you can do it in a couple of hours and have a finished prototype of a game. This stuff is important when you’re getting started, there’s a real sense of achievement to completing something.

Make An RPG in Unity and C#, by HardlyBriefDan 

This is another, highly in depth video series that’s worth following along if you’re particularly interested in building Role Playing Games ( or porting them to Unity as I will be with Everyone Gets Treasure ). Dan has a laid back coding approach and his tutorials are easy to follow along with. He takes his time explaining basic concepts, and updates the videos each week. The first 20 or more videos are strictly coding, so you won’t see any results in your game for quite some time, but I do recommend this series because it goes into some interesting concepts like object inheritance, random name generators, inventory systems and so on.

Unity 4.3 2D Tutorial: Getting Started, by  Christopher Pollo

sprite_packer_atlas_groups

Another really helpful and user friendly tutorial for beginners, particularly focusing on Unity’s 2D capabilities. It covers everything from square one of creating your first project in Unity through to a finished, top down 2D shooting game with fully animated cartoon characters. Great tutorial and very easy to follow along with , though I’d ignore all the sections on User Interface because they’re out of date now.

Unity3D Tutorials by John Stejskal

stateManagementUnityFeature
I’d like to give a shout out to my dear friend and all round game development prodigy, John Stejskal. He’s learning Unity and the moment and has written a couple of tutorials which you’ll find very handy ( and they even use sprites from StreetFighter II for reference! ) . Here’s his first two, check them out and bookmark them!

Closing Thoughts

Unity is a powerful, powerful beast. It’s very easy to get things happening fast. Cubes bounce around a screen, particles explode and skyboxes glow in the distance. It’s also very easy to hit a wall and wonder what the hell you’re doing. I’ve come from Flash, where I know exactly how to do everything from complex pathfinding, to pixel shading routines to realtime multiplayer games, so to go from that to wondering how to get your cube to rotate and move can be a humbling experience. It’s a temporary helplessness though, it too shall pass – like all those who learn new skills, there can be a learning curve and there will be walls you will hit. You’ll break through them though, many of you much faster than I have been. The stuff I’ve seen people build with using Unity is phenomenal. Even big players like Sega are using it. Check out Sonic Dash for the potential of something you could make – it’s blisteringly fast 3D on a mobile device, rings spinning, water shimmering and a familiar blue furball of energy rocketing along a maze. All in the same game creation tool you now hold in your hot little hand.

Stay with it, every day you will have a new ‘a-ha! I understand now!‘ moment which will push you further. In 6 months you’ll be a Unity force and have the skills to get started building just about any game you can think of. Unity is taking off worldwide in popularity, companies everywhere are starting to ask for Unity game developers and designers; it’s going to be around for a long time yet and you can be part of its rise and rise.

Best of luck with your game creations, I’m looking forward to being on this exciting adventure with you!

Cheers and as always, happy journeys.
Oliver Joyce

 5489 people have viewed this page.