Unity3D hands-on first impressions

Today I got together with my buddy Adrian who is a big-shot special effects guy, with the aim of trying to punch through the Unity3D learning curve and get some kind of game going. (Adrian is using the Mac in the photo, and for fairness I should point out that he was pulling that face as a joke). Adrian does Maya so he was able to grok the Unity IDE much quicker than me, as there are a lot of keyboard shortcuts you need to know (e.g. press "F" to focus the IDE on a selected object). I, on the other hand, had installed Visual Studio C# Express, so I had intellisense for coding :)

Here is my effort - MatrixPong. I had intended to post the actual game, but it crashes Firefox (see below), so I thought I'd give it a miss. All in all it was a very worthwhile session, and here's what I learned:
  • You really do need to learn the Unity IDE shortcuts, e.g. Q, W, E & R to switch between tools, F to focus on the selected object, ALT-DRAG to rotate camera around object, drag with right button to point camera.
  • We could find no way to look through our camera in the scene view which was annoying.
  • If you edit the scene while you have the game running or paused, as soon as you stop it reverts all the changes you made. This is a massive gotcha and you can lose a few minutes work every time you forget your game is running.
  • Errors in you game can easily crash the Unity IDE and the browser plug-in. In fact they don't even have to be code errors. For example, in MatrixPong, when the ball goes off the edge of the playing surface, it will fall with gravity for about 10 seconds, then when its position reaches a big number (e.g. y = -1000000000) everything suddenly crashes. For a Flash guy this is a real WTF. Imagine if setting your movieclip too far off the stage crashed the browser!
  • You get loads of stuff "for free" in Unity, most importantly collision detection and physics - this is a big advantage over the other 3D game development framework I have played with, Microsoft XNA.
  • The documentation for scripting isn't that great and it's all JavaScript not C#, although all the method names are the same so it's pretty easy to convert in your head, you just can't copy paste. C# is a great language, but if you don't already know it, it might confuse you. For example you can't type "x = 1.173" if x is a float. It has to be "x = 1.173f". I have never understood this, but there you go.
  • Thanks to Lucas Meijer I was able to set up Unity3D code completion in Visual Studio. Very cool.
  • Everything in Unity3D C# extends MonoBehaviour and relies on overriding a bunch of event functions, e.g. Update and OnCollisionEnter. You don't actually use an override keyword though which makes it hard to know from example code whether functions are built-in or not. I couldn't find a good way to get a list of these functions while typing code though, I had to look them up from the website.
  • MonoBehaviour has tons of stuff in it and I only scratched the surface of what it can do.
  • There's also a big global god object called GameObject where you can find things from your scene. There are lots of global, not very OOP things in Unity. Get over it!
  • Pointless observation: MonoBehaviour has a British spelling for behaviour, the first British spelling I have ever seen in a language API.
  • I created 3 scripts - PongBall.cs, PongPaddle.cs and PongAI.cs. Each script was only about 5-10 lines of code, but that was enough to get the ball bouncing back and forth, the AI paddle following it and the player paddle controlled via keyboard. You drag these behaviours onto your game objects rather than having game objects that extend them. Objects have scripts rather than are scripts like they would be in Flash. Basically it's like Director, but in a good way.
  • To devote the necessary time to get really into Unity I would need a paying gig, so could someone please hire me to make something with it? Thanks!


Unknown said…
Any browser or IDE crash that happens is most defenitely a bug in Unity. Unity engineers want to make very sure that this does not happen. If you could post any information you'd have (like the projectfolder making your browser crash), they would greatly appriciate receiving that, so they can fix their webplayer, so you won't get crashes.

There used to be (is?) a problem with firefox, in which it crashes when a nullreference exception happens. Safari is fine. I think it had to do with Firefox trying to be smart and having some deep OS hooks to install their own crashhandler, which is a bit "too eager", as it doesn't let the unitywebplayer deal with the nullref exception, as it should.

Glad the VS project stuff helped, and yeah, the f postfix on a float is annoying. The default for c# is apparantly a double.

Not sure which unity parts you'd consider to not be very OOP, I personally feel Unity is quite elegantly divided up in multiple seperate components.

The fact that stuff like Update and OnGUI() are not overrides is a silly oversight that I hope the unity folks will be able to fix (without breaking bw compatibility, might not be that easy)

Bye, Lucas
Iain said…
Thanks for your feedback lucas. Where should I post my error report?
Unknown said…
In Unity, go to Help->Report a problem.
diamondTearz said…
Yup- I lost about 3 hours of adjusting by forgetting that I was in play mode also. U gonna show us what you got?

I added you to the reddit at http://www.reddit.com/r/Unity3D/comments/8lltc/unity3d_hands_on_first_impressions/
Oyunlar said…
Really,very super!
Ben said…
Nice writeup. It's funny how the docsmake it sound like it's an advantage that Unity forgets your changes once the game is running... There must be some architectural reason why they do that, because it would make a ton of sense to let folks edit params on the fly.

Also, thanks for pointing out the F key. Somehow I'd overlooked it.