====== Lab 1: Playing with Unity ====== ===== Goal ===== The goal of this lab is to simply get familiar with the basics of Unity through exploration. There are a few things that you should look into - listed below - but otherwise, you are free to make whatever you like. Sort of like playing in a sand box. ===== Preparation ===== You need to install Unity 3D on your own machine before you start. You get the latest version from the [[http://unity3d.com/unity/download|Unity 3D download page]]. ===== Procedure ===== - **The Unity Interface** The first thing to get familiar with is Unity's user interface. You can look up the purpose of each element on the screen in [[http://docs.unity3d.com/Documentation/Manual/LearningtheInterface.html|Unity's "Learning the Interface" documentation]] or by wathcing their [[http://unity3d.com/learn/tutorials/modules/beginner/editor/interface-overview|"Interface Overview" learning video]] (use headphones for watching videos! ;-) ) - **Make a Ground** When you start a new project, the only GameObject you have is the ''MainCamera'', giving you a point of view into the environment you are constructing. Now add a second object, which will serve as your ground. From the main menu select **GameObject->CreateOther->Plane**, this will add a large flat object to the scene. If you now selct your ''Main Camera'' object from the Hierarchy panel, you may see from the little Camere Preview pop-up window that this ground is not visible due to the relative position of these two ojbects. You can place objects precisely in the world by adjusting the ''Position'' property of the object in the **Inspector** pane. From **Hierarcy** select ''Main Camera'' and then in the **Inspector** give the camera the position (0,1,0) in the **Transform** component. Now select the ''Plane'' and give it the position (0,0,0). You should now be able to see the ground in the camera previw. Press the **Play** (in the play control panel above the 3D view) button to confirm that when you run your environment you will see the ground below you and the sky behind it. Press the **Play** button **again** to **stop** running the scene (there is no stop button!). - **The 3D Scene Interface** While you are developing it is very important to be able to navigate the 3D scene you are constructing and to be able to adjust the properties of objects (e.g. position) from within the scene itself. The quickest way to start navigating the scene is to press and hold the **right mouse button** and then use the familiar game control buttons **W, A, S, D** to move. But understand that you are simply moving the point of view of the developer in the world and not changing what the user sees when they enter the world - they will always be bound to a particular camera. Get familiar with this 3D navigation and how you can interactively manipulate game objects by reading [[http://docs.unity3d.com/Documentation/Manual/SceneView.html|Unity's "Scene View" documentation]] - **Add Lights and Objects** Select **GameObject->CreateOther->Cube** and place the cube so that you can see it from the camera when you play the scene. Then select **GameObject->CreateOther->Directional Light** and see how adding the light changes the way things look. Bring in more objects, both lights and geometry, and experiment with their placement (manipulating them in the scene view) and properties (through the **Inspector** panel). - **Add Shadow** Select your ''Directional light'' and change the ''Shadow Type'' property to ''HardShadows''. You should now see your objects casting shadows in the scene. - **Add Fog and Sky** Select **Edit->Render Settings** and turn on the ''Fog'' property (check box) and experiment with its settings, see if you can create the effect of having more distant objects appear faded. In the same settings panel, pick a ''Skybox Material''. If you click on the little circle next to the property, it will show you a selection box, from which you can select a material to assign to this property. Type ''sky'' in the search box to limit the view to assets with the name ''sky'' in them. Pick something and see how it looks. Experiment with this. - **Enable Walking** From the **Project** panel, select the **Assets->StandardAssets->Character Controllers** folder and you should see that it contains two "pre fabricated" (Prefabs) character controllers. Drag the ''First Person Controller" into your **Hierarchy**. You then have to position this object such that it is standing on top of your ground. When you press **Play** you can now walk around your environment in first person. - **Register in the Unity Asset Store** For additional assets, including more models and materials, you can browse the Unity Asset store by selecting from the main menu **Window->Asset Store**. You will have to register there to actually download assets, but is is definitely worth it. After you import assets, you will see them in your **Project** panel, from which you can drag them into your scene. You can always drag things like textures directly onto your objects to "paint" them. Try that. - **Go wild** Make any kind of environment you wish.