Unity3D Hello world

Unity: Starting Up

Hello Unity World

In this tutorial we will explore some basics of Unity3D. The idea behind this tutorial is to briefly illustrate how Unity is actually only one piece of software in an extended pipeline of VR software development. A second piece of software that I highly recommend you get acquainted with, is Blender. Conveniently, I have put together a few tutorials on Blender that you could consult (available here).

Unity: The GUI

Some of the most important aspects to understand about Unity3D, which will also help you in other pieces of software such as Blender and other graphics related packages (e.g. Photoshop, Illustrator, AutoCAD etc.), are layers and the inspector. The layers panel in Unity3D is known as the Hierarchy and in the standard workspace located on the left of your screen. If you right-click on the Hierarchy a popup menu will appear; select 3D Object and then Plane. A new Plane will be added to your scene. This brings us to the second fundamental component that underlies Unity and Blender, namely the inspector. On the right side of the screen you now see a new menu. This is the inspector, basically a tool through which you can adjust properties of your currently selected object, in this case the Plane. Once you get better acquainted with Unity and Blender, you will notice other similarities, for example the Camera object and the Directional Light object.

Moving the camera

Using the inspector, we can move things around in a systematic way. Select the Camera object, either by clicking on it or selecting it in the Hierarchy. You will notice a little preview screen pop up (a very convenient feature indeed!) and that the inspector has updated. Now, with the Camera selected, under the Inspector's Transform dropdown menu, change the Position coordinates to 0, 1, and -3, which will move the object around in threedimensional space.

Make a material

The plane looks a bit white; we can change that by making a material for it. One aspect of Unity we have not yet touched upon is the Project window below. This little window is essentially a direct reflection of what is stored on your computer in relation to your current Unity project; any changes you make in this little window will directly affect files stored on your computer. Let's see how this works. Right-click on the Assets window > Create > Folder. This will create a new folder on your hard drive in your project folder. Generally, it's good practice to systematically organize your files, particularly if your projects get larger and larger. Rename the folder you just made to Materials (select it and press F2). Double-click the folder to open it and then right-click again: Create > Material. Rename the new material to Plane and If you select your new material the inspector will update accordingly. For example, you can now assign a new color to the Plane Material; change it to black. You can now simply drag your Plane material onto the Plane object in your scene to apply the material.

Make a 3DText

Right-click on your Hierarchy and select 3D Object > 3D Text. This will place a new 3D Text object on the Plane. Update the Location of this text to -3,  1.7, and 3. If you click your Camera object, you'll be able to see the text. However, it looks quite pixelated-- not particularly nice. We can change that. Select your 3D Text object and update the Scale property to 0.1, 0.1, and 0.1. Then, change its Font Size to 150.

Colliders

Colliders basically determine what physical behavior and effect objects should have. We are going to add a Box Collider to the 3D Text to give it 'body'; as is, the 3D Text object currently has no mass. Select your 3D Text object and on the inspector click the Add Component button. In the search box, type Box Collider and select it; do this again for a Rigidbody component and add that too. Make sure that under the Rigidbody component's dropdown Use Gravity is checked and Is Kinematic is unchecked. You will notice a green case surrounding your 3D Text object; at this point it has mass. Unfortunately the text itself stays flat (something Blender allows you to extrude; 'assets' to Unity can provide this functionality). To give the text some width, look up Size under the 3D Text object's Box Collider's dropdown menu and set the Z to 1; you'll notice the box expanded a little bit.

Add Box Collider and Rigidbody components to the Plane object as well, but we will give your Plane object somewhat different behavior; this time, uncheck Use Gravity and check Is Kinematic. This will effectively turn them into what Blender calls 'passive' elements. The Plane will not be subject to gravity, but will respond interact with the 3D Text object.

Bye Unity World

Let's add something for our text to interact with. Add a Sphere in the Hierarchy pane (right-click > 3D Object > Sphere). Select the new Sphere object and change its Location to 0, 6, and 3. The Sphere object has now dissappeared from your screen, but is in fact hovering above the 3D Text object. Apply a Rigidbody component to the Sphere object and under the Rigidbody dropdown change the Mass to 100.

Finally, we have Unity play us some magic; just press the play button and see the ball smash your text!

Fun-fact: fiddle with the height of the Sphere object; change it's Location to 0, 60, and 3, and press play again! This time, Unity is modeling physics differently. Just for kicks, try increasing the Scale of the Sphere object to 5, 5, and 5; or make it tiny! Change it to 0.25, 0.25, and 0.25; or even change its shape by setting its Scale to 0.25, 1, and 0.25; so many ways to destroy the world! :)