Unity (also known as Unity3D) is a game engine an integrated authoring tool for creating 3D video games or other interactive content such as architectural visualizations or real-time 3D animations. The editor runs on Windows and Mac OS X and can build games for Windows or Mac standalone (desktop executable), iOS (iPhone or iPad), Android, XBox360, Playstation 3 and Wii. It can also produce browser games that use the Unity web player plugin, supported on Mac and Windows.
The Unity editor will work on Windows on Mac and, as of 2010, Unity is free to download and use. Using the free version is it will show the Unity logo for a few seconds in each build, a few features are missing (eg: dynamic shadows and turning videos into textures) and you can't build for iPhone or any other mobile or gaming devices (see licenses). You can however, build to the web player and PC and Mac standalone. To access the extra feature Unity Pro is ~$1500 US, and being able to build to iPhone is an extra $500 (see pricing). (these prices updated as of Dec 2010)
- Unity - Scripts - some general snippets/examples of camera movement etc.
- Unity - Web Interaction - code snippets and tips for interacting with, loading and uploading data from webpages.
- Unity - Textures - code snippets and tips for dealing with images and textures.
- Unity - GUI Template - suggested setup for a GUI scroll area in Unity.
- Unity - JSON - information about JSON use in Unity (C#).
- Unity - XML - information about XML use in Unity (C#).
- Unity - Drawing Lines - code snippets and tips for rendering 2D or 3D lines.
- Unity - Skyboxes - information on making and using skyboxes in Unity.
- Unity - Mesh - some basic code for generating a custom mesh.
- Unity - Videos - make a YouTube video (or a .mp4) render as a video in your Canvas UI or 3D texture element.
- Unity - Testing on Android - how to test your unity game on an Android phone.
- Unity - Testing on iPhone - how to test your unity game on an iPhone.
- Unity - Detecting Google Cardboard Click - detect the click of the magnetic button on a v1 Google Cardboard VR device.
- Unity - Importing an Animated Character from Cinema 4D - how to take a model from Cinema 4D and get him animating (running etc) in Unity.
- Unity - Panorama Viewer - how to make a panorama / photosphere viewer in Unity.
- Unity - Clipboard - how to set the copy/paste clipboard from a Unity game.
- Unity - ScrollView - wish I had this as a more complete page.
- Unity - Errors - some error messages which have bitten me.
Moving Files from Cinema 4D
Unity allows you to import 3D scenes and animation from 3D Studio Max, Cinema 4D, Blender, Maya and Cheetah3D with a simple drag and drop. Since Cinema 4D is my preferred 3D animation package I've written some notes on it below.
To import files from Cinema 4D you simply drag the file into the Assets folder of the project you are working on. Unity will detect you've added a file and when it appears in the Project window you can click it to import it. An important note however, is that if Cinema 4D isn't installed on that computer, you'll have to export it to a "FBX" file. When you do this, a couple of quirks/problems to beware of:
- Spheres are exported as meshes (which is undesirable and can greatly increase file size).
- Textures must all have unique names or they will import as the same texture (eg: a single texture called "mat").
- Mesh normals are often inversed: if you zoom in close to such a mesh you'll notice you're looking at the inside face (not the outer face), and this will do some weird things if you have RigidBodies (things will get trapped inside). To fix this you'll have to select each affected mesh (hold Ctrl) then go: Functions > Reverse Normals U~R before you export. TIP: The best way to find objects which need normals reversed in Unity is turn them on/off individually and move a Plane (Game Object) through them.
- Taking a Rigged, Animated Character from Cinema 4D into Unity - a great tutorial which (as the name suggests) shows you how to build a rigged character, animate it, and then import into Unity.
- Cinema 4D - my C++ plugins - object converter - a Cinema 4D plugin I created in C++ to help reduce large models.
Tips and Tricks
Making your own Custom 3D Font
To insert 3D text into your scene you can simply go: GameObject > Create Other > 3D Text. Since the default font (Arial) is quite pixilated, you'll probably want to create your own font and/or font color by the following steps:
- Create or download a truetype font file (.ttf) from a site like: 1101freefonts.com or fontsforweb.com
- Drag the font from your Desktop/Explorer to the Project window, so unity can import it.
- Expand the new font that has appeared and notice Unity has generated a "font material" and "font Texture". NOTE: In Unity 3 you can't rename/alter either of these, but fortunately you won't need to.
- Insert a new 3D Text GameObject by going GameObject > Create Other > 3D Text.
- In the text's Properties window change the font (under "Text Mesh") to your new font AND THEN change the material (under "Mesh Renderer / Materials") to your new "font Texture". Without changing the first material the text will look very strange.
- To create a new color for this font, click "Create > Material" in the properties window. Rename your material "CustomFont - Red". Change the material's shader to "GUI/Text Shader" select your "font Texture" and then set the color your desire. Now when you add text you can add this material instead of the default (white) "font Texture".
WARNING: In some situation and some platforms (especially building for phones) you may see an annoying error: "Font size and style overrides are only supported for dynamic fonts". You can try downloading a different font (I like Facet), but if that doesn't work you may have to turn the font's "character" from "dynamic" to "Unicode", give a desirable font size and apply. For each 3D Text GameObject, or even GUI text implementation, you'll need to set it to "regular" with a font size of "0" and it should finally work. What sucks about this is you'll need a separate font for each font style and size you want, but this may be price you have to pay to build to a greater number of platforms (see discussion here).
If you want to learn Unity, the best way to get started is with the online tutorials (which you can download and work through). Graham showed me Unity in Nov 2010, and I decided to have a bit of a play. I went through and recommend these two main tutorials:
- Car Tutorial - a car racing game where you start with the track, add a car and then attach quite a few complex scripts to it.
- 3D Platform Game - a third person platform game where you can jump around floating platforms, avoid lasers, punch enemy robots, collect fuel cells and eventually escape on your rocket ship. This teaches you some great concepts, and how to add some fantastic particle/rendering effects (jetpack, lasers and forcefield), but be warned it will take you a day or two to get through successfully (save backups as you go)! I've uploaded a browser version of the finished result here - but be warned it is 20 MB, so will take a while to load!
On the Unity website there is an increadibly impressive highlight reel. Some of the games which most impressed me:
- Max and the Magic Marker - a brilliant, award-winning spin on a 2D platform game where you navigate your character and draw objects for him to climb on/interact with.... although sadly I found the demo crashes sometimes.
- Blush - a 3D web game with stunning graphics: where you control a jellyfish, collect eggs on your tentacles and use them to whip enemy sea creatures..
- Off-Road Velociraptor Safari - an off-road driving game where you run-over and catch dinosaurs.
- Plankton - A game where they've created a fantastic underwater environment, and you must swim a single plankton around a small reef, finding other plankton and avoiding sea creature which may eat you. Sadly the game-play is very short!