Goo Goo Geiger! A Game for Molyjam 2012

2 04 2012

This weekend was the first Molyjam, based on the ideas of Peter Molydeux. The jam took place over 48 hours with hundreds of games made globally. Lots of sites have detailed the jam already, so I’ll cut to the chase and talk about mine and Mark’s game…

We decided to make a game based on the following tweet:

 

“Imagine carrying a radioactive baby in a pitch black environment, your baby would act as a torch. Rocking the baby intensifies the glow etc”

 

 
The details of the game can be found on www.whatwouldmolydeux.com, and it can be played at http://www.catburton.co.uk/molyjam2012/.

 

Enjoy! :)





Testing Unity’s Flash Export on a Large Project – Part 1

20 02 2012

Over the last weekend, I’ve been hard at work trying to get an unannounced Mind Candy project (made in Unity) to export to Flash.  I thought it would be useful to share some details from the experience since most of the issues I’ve encountered would probably be avoidable if your project is architected in a way that lends itself to Flash export.

During the Christmas holidays, I made a game for Unity’s Flash in a Flash contest. It wasn’t the most exciting game, but it worked. The core mechanic of that game (including new 3.5 features such as nav mesh) exported to Flash well. The reason this game worked is because I had been paying close attention to the Flash export and knew what features wouldn’t work at that time. I avoided anything overly complicated and developed the game with the limitations in mind. Fundamentally, I decided to make a new, simple game rather than trying to port an existing one.

Now, I’m doing the opposite. I’m trying to get an existing game to publish to Flash. This project is a relatively large one. The game has been in development for quite a long time. It contains a lot of complex C# code and most importantly: a lot of features that don’t yet work in the Flash export. Trying to get this game to export to Flash is no easy task. I’ve spent numerous weekends on this since the 3.5 beta was made available and I still haven’t got it to work.

Despite the export (currently) not working for our project, there are a lot of lessons to be learned. Hopefully these will be of use to other people attempting the same task, and will be a good reference point for myself when I inevitably try to export the game again at a later date.

 

Currently Unsupported Features

Unity have already listed some of the unsupported features in the Flash export as part of the 3.5 preview faq. Some of these features (and the ones that have proved most problematic for me) are:

  • LINQ
  • Terrains
  • Asset Bundles
  • WWW
  • Raknet networking

If you’re using these features, then you’ll encounter a lot of errors as soon as you try to get Unity to build to Flash. Some example errors I’ve seen are:

 

Networking

  • error CS0246: The type or namespace name `ConnectionTesterStatus’ could not be found. Are you missing a using directive or an assembly reference?
  • error CS0246: The type or namespace name `NetworkView’ could not be found. Are you missing a using directive or an assembly reference?
  • error CS0246: The type or namespace name `BitStream’ could not be found. Are you missing a using directive or an assembly reference?
  • error CS0246: The type or namespace name `WWW’ could not be found. Are you missing a using directive or an assembly reference?

 

MovieTextures

  • error CS0246: The type or namespace name `MovieTexture’ could not be found. Are you missing a using directive or an assembly reference?

These errors are effectively a checklist of all the classes you’re using that aren’t yet supported and there’s only one thing you can do: remove them from your build. There are numerous ways to do this (depending on what you’re trying to achieve), from brute force deletion to telling Unity to skip these sections in a Flash build. You can do the latter by using platform dependant compilation.

All you need to do is wrap your Flash specific code in a platform check such as:

#if UNITY_FLASH
Debug.Log(“Flash build”);
#endif

In my case, the first thing I had to do was to try and remove these unsupported features. MovieTextures were easy to take out, as they’re not vital to our game. Networking, however was more problematic. And this is my first (and most important) lesson…

 

Lesson 1 – Separation of Networking Code

Our game currently uses the inbuilt RakNet networking solution. These networking elements are fundamental to our game, and as such, the networking code exists in many different areas of our codebase. When publishing to the web player or a standalone app/exe build this is fine. For Flash export, this suddenly creates a big problem when the networking solution isn’t yet supported.

As an example, if your game uses RPCs across clients to update core data in your game, then you’re going to have problems. I’m sure that there are other solutions which are better suited to Flash export, but this doesn’t fix my immediate problem: we have a game, where our chosen networking solution won’t publish to Flash. Unity suggest that you can use Flash networking instead of RakNet, but since I’m doing this export with tight time constraints (self imposed, by the mere fact it’s a weekend), that solution is not feasible for this test.

This has left me with one option in my mission to get our game working: rip out RakNet. This is not ideal, but luckily, our game copes with it ok.

This raises an interesting point in that the networking code should be as decoupled from the core mechanic of your game as possible. In some cases this can’t be done, but if you can find a way to make your networking layer easily removed/changed, then you’ll be in a much better place than I was regarding Flash export. It will also help you if you ever decide to switch to a different networking solution.

At this point, I’m going to gloss over about 10 other failed builds. It takes a few attempts at building to clear up this first wave of errors. Once you’ve cleared that first wave, you can breathe a sigh of relief and ready yourself for wave two: Attempting an actual build…

 

Attempting a Build

Once you’ve fixed/removed/hacked-out all the unsupported features, you’ll get to a point where the build process will now try to publish your game to Flash. The type of errors you get now will be more complex than those in wave one. Below is a screenshot of one of my build attempts at this stage:

 

You’ll note that these errors are more complicated than the “you can’t use ClassX because it’s unsupported” ones. In the case of these errors, it’s up to you to go into each of these classes and try to simplify your code as much as possible.

Some areas where our build failed were where we’d used generics. For example, we had fairly complex code to randomise the order of elements in an array. It wasn’t vital, so it went in the bin. This seems to be a common trend in trying to get this project to build to Flash. I’m slowly, over time, discarding features to the point where it’s a very stripped-down version of the game.

There are a couple of errors regarding our audio library in the above screenshot. This library wouldn’t convert at all (I got multiple waves of errors). My only solution at present has been to remove it.

The last item in that list is log4net. This caused a lot of issues. Rather than spending ages resolving them for this test, I decided it should also be removed. Since we used the logging in a lot of our code, I’ve ended up writing my own logging classes based on the log4net interfaces. This meant that I only had to fix up the imports in the class and our existing logging would still work using Unity’s own Debug.Log etc.

A few more iterations and build attempts occurred before wave 2 was complete. All in all, the first two waves have taken out large chunks of our features, and as a result the game feels somewhat unstable.

Akin to a game of [insert zombie survival FPS game of your choice here], we’ve just about survived the first few waves. We’re battererd, we’re bruised, but most importantly, we’re not defeated! We’re now ready for the next wave. Bring on the boss; the tank; the last major hurdle in the flash export – the conversion of your code to ActionScript.

 

Converting your code to ActionScript

At this stage, when you try to build, Unity will attempt to convert your source to ActionScript. Having previously spent years as a Flash developer, I find this part of the build rather exciting. The guys at Unity have done a fantastic job of getting this process to the stage it’s at.

That said, this is probably the toughest part of the process. Ripping out features and (to some extent) fixing the errors in the previous stage is easy. Trying to work out why the generated ActionScript doesn’t work is much more difficult. Luckily, when a build fails, you can find all the AS classes in a temp folder in your project (/Temp/StagingArea/Data/ConvertedDotNetCode/global/). This will enable you to look at them (if you wish) and try to understand where it might be going wrong, such that you can adjust your C# or js accordingly.

In my first attempt at this stage, I was left with 87 errors. The following are a small selection of these to give you an idea of the kind of problems I’ve seen:

 

Conversion Error 1

  • Error: Access of possibly undefined property $Type through a reference with static type Class.

This error seems to be very common and occurs when reflection is used (and probably in other situations). Unfortunately, a lot of our core libraries use reflection, and as such, this is a large problem to try and fix.

 

Conversion Error 2

  • Error: Call to a possibly undefined method IComparable$1_CompareTo_T through a reference with static type Number.

This has occurred because we’re trying to compare two values whose classes implement IComparable. In our case, this could be worked around relatively easily.

 

Conversion Error 3

  • Error: Type was not found or was not a compile-time constant: ReadOnlyCollection$1

In some of our classes we’re providing access to ReadOnlyCollections. It seems that we can’t use these at present and we could work round this by simply returning a standard Collection.

 

Conversion Error 4

  • Error: Call to a possibly undefined method String_Constructor_Char_Int32 through a reference with static type String.

A common style of conversion error that’s quite tricky to work out. I saw a lot of errors similar to this one.

 

These are just 4 of the 87 errors which need fixing. I expect that if/when all 87 are resolved, I’d have another wave or two to get through before the game would actually build. For now though, it’s Sunday night and I’ve run out of time to work on this test.

 

Next Steps…

My next challenge in this Flash export test is to go through the aforementioned 87 conversion errors and try to resolve them. I’m hoping that I’ll be able to get the game to build after another solid few days working on the export.

If that task proves too difficult then I will try a different approach of starting from a clean project and adding features one by one. In theory, that should be easier to get working, although that’s not how we’d want to export to Flash in the long run.

If I do get the export to work, I shall write a follow-up post with a walkthrough of some conversion errors.  For these, I’ll include (where possible) the raw C#, the converted AS, and examples of how the errors can be avoided/solved.

For now though, I’m going to give up and play some well-earned Killing Floor! :D





Learning Blender – Some Useful Links

15 01 2012

I’ve been trying to learn the basics of Blender in the last few weeks and have struggled to find a good list of learning resources. Rather than keeping my own list of useful tutorials/links, I thought I’d create a list here. I’ll continue to add to this as/when I find resources:

 

 

Only a short list for now, but those are a good starting place. If you know of any other good resources that I’ve missed, please let me know, and I’ll add them!





Making “Find Heidi” for Unity’s Flash in a Flash Contest

5 01 2012

The Christmas holidays are usually a time of relaxation, time to put your feet up and unwind after a busy year. That was indeed how it started, until Unity announced their Flash in a Flash contest!

As part of the Unity 3.5 public beta, Unity have given us a sneak preview of the upcoming Flash export. While not all features you might currently use for your games are supported yet, there are a lot that do and the export works rather well. And so on 22nd December, Unity set the community a challenge. We were to build “the best Unity-based Flash platform game or interactive content”. The deadline for this contest is 5th Jan at midnight PST.

I was back in rural Lincolnshire for the holidays, meaning I only had my 4 year old MacBook with me. It was so old I couldn’t even install Flash Player 11. I had to wait until after Christmas, but as soon the shops re-opened I hurried out and bought a new MacBook. The game dev could finally begin. It was already almost a week into the contest by this point, so the pressure to get something started was quite intense!

I’ve never participated in a game jam, or made a full Unity game by myself before. Nor have I had to make something in Unity with such a tight deadline. Not only that, but I had no real experience with game design or audio, and no 3D modelling skills! I am used to working on large Unity projects, in a team, with talented artists and designers. This was going to be tough!

My game concept started being the story of a toy (perhaps a small robot or doll) that was left in the house alone. I liked this idea, but realised the modelling for that would be beyond my ability for a quick project. After much thought, I decided on the idea of a mouse/hamster.

The plot of the game is as follows: You play the role of Max, a mouse who has escaped his cage and is searching for Heidi (who I see as his sweetheart, aww). Heidi and max have been separated into two children’s bedrooms, those of Timmy and Lucy – we don’t yet see them in this version of the game. Max must search through the house until he finds Heidi. There is, as always, an arch nemesis for our hero. This enemy is called Bruce; a somewhat evil cat with a penchant for chasing mice.

This was quite a large game to try and make within a week. Coming up with viable levels in different rooms was quite difficult. However my main issue was a complete lack of experience in 3D modelling. I was unable to find characters in the right style on the Asset Store and so I had to try and power-level some skill at using Blender. My first attempts at modelling Max and Bruce weren’t too bad and I kept these in the game for most of the game’s development time. It wasn’t until the last couple of days that the lovely @zafio very kindly offered for me to use the cat/mouse models you now see in the game.

The game as it currently stands has 5 levels, each representing a different room in the house. All artwork/models except for the mouse and cat were made by myself – so while it may look a little rough round the edges, I am really happy that I managed to pull it all together! Coder art FTW!

The game makes use of some of the awesome new features that will be released in 3.5. Bruce navigates the room using the fantastic new NavMesh feature. It doesn’t take much work at all to get him following Max around! I also tried out the new occlusion culling which seems to work really well. The time to bake these scenes was very short – which is handy when you’re rapidly prototyping a game but also needing to keep performance high! I also had a play with the new particle system for the fireplace in the lounge level. That system is much more advanced than the one you’ll find in 3.4.

I’ve now submitted the game to the contest and am looking forward to seeing everyone else’s games. There are a lot of very talented people in the Unity community and the entries I’ve seen so far on twitter have been brilliant!

I will continue to work on this game now that it has been submitted. I have lots of ideas that I didn’t have time to implement in the last week. These include:

  • Actual artwork & animated models – there’s only so far you can go with coder art
  • Level specific audio
  • More levels – kitchen, attic, hallway, bathroom etc
  • Full overhaul of the menus/gui
  • Different game modes – I’d like to make a mode where you control Max in a hamster exercise ball – would be fun to implement.

That lot will probably keep me busy for a fair while. Still, it’s nice to finally have a side project!

Below are some screenshots from the game. If you’d like to play it, you can do so here (you’ll need Flash Player 11 installed).





Unity Web Player Cache Location on OS-X

8 12 2011

I’ve spent this week looking at using Asset Bundles for our Unity project at Mind Candy. And since we’re using them, it makes sense to take advantage of the webplayer cache. For this, we’re making use of the WWW.LoadFromCacheOrDownload function.

Testing whether this cache is used/updated correctly proved difficult at first as I wasn’t sure where the cache files were stored on OS-X. I could see the cache files were being created using Unity’s Web Player Settings page, but I wanted to double check the versioning was working as expected.

Anyway, some failed googling and trawling of my Mac later, I’ve found them:

/Users/[username]/Library/Caches/Unity/

Hoping this will save fellow devs some time hunting them down!





A Little Bit of Astrophotography

9 11 2011

I had plans of finishing more Dead Island tonight before Friday (yay Skyrim)! However, the moon and Jupiter looked so lovely that I ditched gaming in favour of some amateur astrophotography. I think it was an evening well spent… :)

 

Jupiter’s Moons and a Cloud Hiding Ours
Jupiter's Moons and a Cloud Hiding Ours

The Moon and Jupiter
The Moon and Jupiter

A Close-Up of the Moon
Close-up of the Moon





Unite11 Notes: Creating a browser-ready FPS MMO in Unity

29 09 2011

Session overview: “Creating a browser-ready first-person shooter MMO in Unity presents massive gaming opportunity but also a set of unique client-server challenges. Join the developers from Aquiris Game Experience and Electrotank as they discuss the hands-on lessons they learned in creating an upcoming free-to-play FPS MMO for PC/Mac and the browser.”

A very informative session by guys from both Aquiris and Electrotank. The session started with a realtime demo of Aquiris’s FPS. The game looked fantastic, particularly their UI which they wrote themselves in OpenGL. That effort clearly paid off as the game is gorgeous! The multiplayer element seemed to work really well, with them demoing against a team of guys in another studio.

 

Artwork challenges/considerations encountered when making the game:

  •  They made a basemesh covering entire level: max 50k tris, max 30 objs, max 3k tri per obj
  •  Smart texturing – They limited textures to a maximum of 30 textures. 50% tileable; 25% trim; 25% unique.

 

When developing the game, they made automatic import tools to handle the setup of the many weapons and maps. Extensively used asset bundles and then because it was taking too long to build the project they developed their own tool to enable you to toggle which bundles should be built. Rather than storing weapon data in xml/json etc they used scriptable objects to store this info. For map details, this was stored in xml on the server, sending the client the correct map config at runtime.

During development, they had a number of networking options available:

  • Unity’s built-in networking – Their opinion of this is that it’s good for small games. Nice features mentioned include the fact it’s integrated and easy to use (easy rpc calls, easy to share objects). However they believe it’s not made for thousands of players per instance. It’s good for local hosted games, but not for 2000+ players on single server.
  • SmartFox – They skipped any comment on this
  • Photon – As with SF, they didn’t comment on this
  • ElectroServer5 – This is the solution they chose because they knew it already works well with flash. ES5 also has good admin tools. It runs on linux and is java based.

Originally the Aquiris team considered using a P2P solution for their MMO but decided on client-server for a number of reasons. They wanted a semi-authoritative server with 100+ matches per server instance and 8 to 18 players per match. During development, the networking layer was separated from gameplay by making the solution event driven.

 

ElectroServer5:

  •   ES5 nodes handle realtime simulation, persistence.
  •   Distributed simulation / load distribution.
  •   Runs on EC2 – scales to meet requirements
  •   EUP handles matchmaking, loadout etc
  •   MatchNodes – register themselves with EUP. Can add/remove themselves at any point.
  •   Protogen (protocol engine) is described on their site as “a framework to support creating protocol specific objects dynamically via a simple declaration file. Protocol message objects (client and server) and their codecs are generated by EUP, saving developers significant time and effort.”




Unite11 – Exporting to Flash from Unity

28 09 2011

I just attended the Flash afternoon at Unite where Lucas Meijer and Ralph Hauwert detailed the latest progress on Unity’s export to Flash. On first impressions, the games they’ve been working on look fantastic! One of the reasons I’ve been keen on working with Unity over Flash for 3D games dev is the awesome toolset, and these guys have really nailed the Flash export.

As long as your code isn’t doing anything too “exotic”, Unity will convert your code (c#, js (strict) and boo) to ActionScript. It will then compile this, along with your assets, into a swf using the mxmlc compiler. One thing to note here is that literally everything is compiled into that one swf. There was mention of them using asset bundles at a later date to generate individual swfs for content such as scenes. Since everything is in one swf, that means file sizes could get pretty large really quickly. One of the demo apps generating simple spheres compiled to a ~1.4mb (iirc) swf which is pretty chunky for something so simple.

The generated AS3 code is pretty readable although since there’s no method overloading in Flash, they’ve had to compromise on function names somewhat! That said, it should be pretty easy to debug your exported app.

 

The features currently supported in Flash are:

  • PhysX
  • Particle system
  • Custom and standard shaders

 

Things that won’t work in the first version include:

  • Anything needing depth textures
  • Advanced audio such as doppler and reverb
  • Dynamic shadows
  • Mouse lock
  • Unity networking (you’ll have to use a Flash networking solution for now)

 

Looking at the performance of the games, they seemed to run pretty well. They mentioned trying to push anything you can to the GPU rather than CPU. An example given would be to animate textures in a shader rather than scrolling it in a script, as well as the usual light baking and occlusion culling. Basically, as Lucas put it: “The best way to make your game go faster, is to have it not do stuff”.

So to summarise – from a first glance, the Flash export looks pretty awesome, and the Unity guys have done a great job getting it working. There are still a fair few features missing, but there should be enough there for most simple Unity games to be exported. Unfortunately, both the release date and the price were listed as “TBA”, so I guess we’ll have to wait a little longer before we can try it out.





Version Control for Unity Projects

25 06 2011

As a developer, version control is very important to me. Any project I work on needs to use version control; not only to use a backup and provide change history, but to enable collaboration with other developers and designers. Since I’ve been developing games with Unity, I’ve not found a resource that highlights the pros/cons of the available version control systems. I’ve not even seen a consistent list of external version control systems that you can use effectively for Unity projects.

Since I can’t find one solid source of information on this, I’m spending my Saturday researching the available options. This list is not in any order of preference, merely the order in which I encounter each system.

 

Asset Server

Asset Server is Unity’s own version control product. It sits on top of a PostgreSQL database and can be setup easily on many platforms. In my case, I installed Asset Server locally on my Mac for trial purposes, and found that once installed, it was very easy to administer and add project-specific user privileges. Note that Asset Server requires an additional license from Unity (an extra $500 per user), and can only be used in the Pro version.

Since it has been developed by Unity, Asset Server is integrated nicely into the Unity UI. Having used this for a week or so, I’ve found that visually, this tool is quite nice. It provides the ability to dock the UI along with your other interface windows and updates frequently, meaning you can quickly see when someone else changes a file, without needing to manually refresh/synchronise.

When you wish to update/commit, you do so using the UI. I’m usually more of a fan of using the command line, but as far as UIs go, this one was ok…

 

Aside from the ok UI and the ease of setup, I have already noticed some rather large features missing in Asset Server that are available in other version control systems. There appears to currently be no way to branch/tag/fork your project. The only way to “tag” a project would be to effectively copy the project to a new one in Asset Server. This means you lose any link with the original project. The same would be said for branching, although by losing this link, I have no idea how you would attempt to merge changes between the two, other than by consuming lots of coffee and manually copying changes over. Personally, I’d rather not be a merge monkey. I need my version control system of choice to deal with this automatically (bar complex merge conflicts, although that would be nice!).

 

Based on my experience of Asset Server so far, I’d say that it might be ok for personal use and small projects. However, I wouldn’t say it’s worth paying the additional license fee when there are more powerful options available for free.

According to the Unity roadmap for 2011, it looks like they’re working on integration of Perforce and SVN in version 3.5. Until then, if you want to use an external version control system, you’ll have to set that up yourself and choose your own client.

 

Links:

 

External Version Control Systems

Although not entirely obvious from looking at the Unity UI, it is possible to use an external version control system for your projects. Again, this will require a Pro version of Unity.

To enable external version control for your project, go to Edit->Project Settings->Editor. You should see the Editor Settings window appear. Hit the Enable button and you’ll see a progress window appear and dismiss itself once done. What this has done is create a .meta file for each of the assets in your Assets folder. These .meta files contain details required by Unity for that particular asset. It is important that you commit those files alongside your actual assets and ensure that the files are kept up to date.

Once you’ve done this initial setup, you should be able to add your project to your external version control system of choice.

More detailed documentation on this is available on the Unity website.

 

SVN

 

The aforementioned documentation has some details on setting up a project in SVN. Effectively, this is all done via the command line. For me, this is fine, but I’m sure there are plenty of people who’d rather have a visual client to work with. I’ve not been able to find any svn plugins for the Unity UI yet, so you may need to use one of the standalone clients. There are plenty out there to choose from – I’ll just link to the handy Wikipedia comparison page rather than discuss any in particular.

One issue you’ll have with SVN (and the other version control systems listed below) is that it will try to merge binary files, meaning you will possibly end up with broken scenes/prefabs etc. There’s a useful discussion on Unity Answers about how people have tried to resolve this issue.

Short of having to lock on a scene/prefab etc, there appears to currently be no easy way to deal with multiple people being able to edit/commit these, unless one person is responsible for combining all the changes. Not ideal.

Looking at the Unity roadmap for 2011, the following (hopefully in the 3.5 release) should fix this issue:

 

“Text-based scene/prefab/… format

Unity will now write all data in a text-based file format for scenes, prefabs, materials and other binary files in your project folder. The format is based on YAML and is optimized for being easy to merge. Multiple team members can work on a scene at the same time and merge the resulting changes afterwards.”


On the same page, they’ve also said they’ll be integrating SVN into Unity 3.5, which will be awesome!

 

“Integrated Perforce and Subversion version control

We’re working on fully integrated version control support for both Perforce and Subversion. There’s a complete UI including support for file locking.”

 

Perforce

 

First a disclaimer: I’ve never used Perforce so this section is very short! I’ve heard a few people mention the use of Perforce in games development studios, so I’ve still researched its use in Unity in case anyone is thinking of using it.

As mentioned earlier, Unity are currently looking at integrating Perforce support in the 3.5 release. For now though, you’ll have to either use a separate command line or client, as per the SVN comments above.

Alternatively, it seems that Downsized Games are working on a plugin for Unity called P4U. The plugin hasn’t been released yet, but you can see some UI screenshots on their website.

 

Git

Git seems to be a bit of a version control hero for lots of people. For those who’ve not used it, it’s free (yay!) and open source (double yay)! You can find more info on Git here.

Researching its use with Unity doesn’t seem to give much information on any specific issues encountered. That said, there weren’t any specific advantages noted either.

One thing to bear in mind if thinking of using Git, is that while it may be pretty awesome, Unity don’t seem to currently have any plans on the roadmap to integrate it into the Unity UI. This may be a drawback for your workflow compared to SVN/Perforce which will hopefully be integrated by the end of the year in 3.5.

 

Others

Other version control systems that I’ve seen people mention they use alongside Unity are listed below. Since I’ve not used these before and I can’t find much information on their use in Unity, I’ll simply list them as possible options:

 

Summary

I initially set about writing this post to give myself a better idea of which version control systems would be best for use alongside Unity. A lot of people seem to like using Asset Server since it is fully integrated in the Unity UI and as such, is possibly better for workflow. That said, Unity are working on integrating Perforce and SVN for 3.5. Given that there are key features missing in Asset Server (branching/tagging etc), the lack of UI integration for a few months seems to be an empty argument.

Since I’ve not used Perforce and already have my own SVN repo set up, I’m going to rock with SVN and look forward to the Unity integration later in the year.





Unity – A Beginner’s Perspective

18 06 2011

I’ve recently been spending my free time teaching myself how to use Unity to develop games.  I’ve always been interested in 3D games dev and thought it was about time I had a go at it! As someone who’s primarily developed 2D apps in AS3 for the last 2.5 years, this has proved to be quite a learning curve! There’s been a lot to try and understand in the last few weeks of evening dabbling: bringing my 3D maths and physics knowledge back up to scratch; learning C# and JS; getting to grips with the UI and dev tools;  and generally tring to find my way around the community and mass of useful resources available.

Figuring I’m currently in a similar boat to most people trying out Unity for the first time, I thought it might be useful to post some of my experiences from the last month or so.

 

Community

The first thing I’ll say is that the community is incredibly friendly and helpful. There’s always someone to chat to should you need help/advice. Places I’d recommend you check out are:

  • The official Unity Forums and Answers pages. Both of these are great places to look if you encounter any issues. As a beginner, I found that a lot of my questions had already been answered here.
  • Unify Community: This is a fantastic resource for tutorials, plugins, shaders etc. If you need to script something, chances are that someone’s already posted a solution either on here, or on the Asset  Store.
  • IRC: #unity3d on freenode. I usually loiter on here most days, idly picking up useful tips and getting to see what cool projects people are working on. Hopefully soon enough, I’ll be able to offer help on there, rather than being the one asking for help. You can find details of the channel on UnifyCommunity.
  • For anyone able to reach London for an evening, I’d recommend popping along to the monthly London Unity User Group. This is a very welcoming group with informative presentations. There’s usually beer afterwards too, which provides a great opportunity to mingle with fellow game geeks.
  • There’s also always Twitter for keeping up to date with what everyone’s currently working on!

 

Tutorials & Learning Resources

As an experienced developer of 2D apps, I think the hardest thing for me to pick up was how exactly I should build games in Unity. How should my project be set up? How do I make game objects react to one another? How do I code custom behaviour? Can I easily make multiple levels?

Luckily, all of these things are relatively easy to pick up in Unity thanks to the mountain of tutorials available. I’ve linked to some below that I’ve had a go at and which I’ve found useful so far:

All of the above Unity tutorials come with a detailed set of notes/instructions. They also supply the basic projects, with all the assets you’ll need to get started.

Aside from tutorials, I’ve also worked through a couple of books. Of these, I found Will Goldstone’s Unity Game Development Essentials to be of a good introductory level. It covers all you need to make a 3rd person game, exploring a 3D landscape with pickups, HUD etc.

Once you’re ready to start coding, you’ll find a whole stash of documentation which comes with your Unity install. These are all available via the Help menu and provide a lot of useful information/tutorials. If you want to know what functionality is available when scripting game objects, this is a good place to start!

 

Unity’s UI and the Dev Environment

Initially, I found it a little tough to get to grips with the UI. After spending most of my time in Eclipse and the Flash IDE for the past few years, everything felt a little alien. However, after running through a few tutorials, I soon became comfortable with the UI. Despite this, there are a couple of areas I’d like to point out that can easily catch out new Unity devs…

 

Beware the Play button…

My biggest issue with the UI to date has been the fact that you can edit elements of the game while it’s running (when the play button is toggled). I can see how this is handy for debugging (the values in the inspector will update in real time), but it can be very easy to forget you’re in playmode. Cue time spent updating settings, only to find that your changes are all lost when you disable that Play button again.

Luckily there’s a handy solition to this which was pointed out by a friend. Behold the mighty playmode tint! If you locate your Unity Preferences panel, go to the Colour tab and change the default tint from grey/black to something a bit more colourful. When you now enter playmode, your UI will be shaded that colour, making it easy to know when you’re in that mode. No more lost changes to your game!

 

Dependancies and Instances

In your project pane, it can quickly become difficult to remember which items are used and which aren’t. You can right click on an item for it to highlight any dependancies, which is useful, except this seems to not work properly for scripts. Still, it’s a useful tool for anything non-scripty!

The thing I’ve found I miss most as a moonlighting Flash dev is some sort of instance count (such as in the Flash IDE Library window). Because I can’t easily see if an item is used anywhere (such as in a prefab or created in a script), it’s hard to know what I can/can’t remove from a project. For larger projects, I can see how this could lead to an unruly and cluttered project pane.

If anyone’s got a solution/suggestion for how to overcome this issue, I’d love to hear it! Otherwise I’m just hopeing Unity can one day add an Instance Count field to the inspector panel… *hint hint* :)

 

Unitron, Mono Develop and Visual Studio

As a Mac user, I don’t have access to Visual Studio by default, and the text editor that is supplied with Unity (Unitron) felt to be massively lacking in functionality. Currently I’m using Mono Develop which has a certain amount of code completion, but is still not perfect. I will no doubt switch to using Visual Studio at some point. For anyone who’s unsure how to set this up on a Mac, there’s a handy tutorial over on quickfingers.net. I think once I have a decent development environment set up, that’ll really help my productivity!

 

So, to summarise my rambling…

After a month or so playing with Unity in my free time, I have to say that I’ve really enjoyed it so far. As someone who just wants to settle down in the evenings and code, I found it was relatively quick to get to grips with the UI and start writing fun features. Sure, I’ve encountered some niggly issues with the UI, but nothing major and most of these have a solution if you look hard enough!

Overall, I’ve found the tools, resources and community means that I’m able to rapidly learn and create exciting games. I were trying to develop the same 3D games in Flash, it would take me MUCH longer. As a tool for games development, Unity kicks ass!

 

So what’s next?

I fully intend to carry on learning Unity and keep developing games. I’ve still got a lot to learn, but I have no doubts that whatever game I’d want to make, I could do so with Unity. As I learn, I shall aim to write more blog posts to help fellow beginners. I’m already plotting one about version control and the Asset Server…

 

Ok, that’s all for now! I’m off to play some games :)