SE 320 – Introduction to Game Development Lecture 3: Unity’s Interface and Concepts Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with TODO) 2/10/20121
Outline Quiz Unity’s interface and concepts Homework Lab 2/10/20122
Quiz Turn off your monitors Do not speak – Violators’ papers will not be accepted 5 min – Violators’ papers will be marked as late 2fall/se320/material/day3/ 2fall/se320/material/day3/ 2/10/20123
TODOs from Last Week Project videos – If you haven’t already sent them, please see my related message in Google group. Homeworks – How you send your homeworks and what you send in them is extremely important. – s without the proper subject make it extremely difficult for Özkan to manage the submissions. – Unity packages without the complete project are useless. Make sure you save your scene before creating a Unity package. To be sure, quit unity. It will ask you to save whatever was not saved. Save them. Reopen unity. If you still have your game working, then exporting the Unity package should not be a problem. – 30% of your homework grade comes from how you submit it the first time (subject and existence of required contents). 2/10/20124
Game Projects Have you formed your groups? Have you sent in your game ideas? We will send you feedback on your game ideas by Friday. You will have time to decide on one revised game idea. – You will present your game idea in front of class next week. (check the TODO item at the end of the slide deck) 2/10/20125
Unity Project Management Project – Various assets (3D models, scripts, materials, texture images, etc.) – Scenes (they use the assets that are in the same project) When you open Unity, it automatically opens the last Project that you have opened. Creating a new project: File -> New Project… When you double-click on a Unity scene file in Windows, Unity automatically opens the project that the scene belongs to. To keep things clean, create a new project for every homework. 2/10/20126
Unity Game object – component relationship – Game objects are empty placeholders in the world. They do not have any functionality by themselves. – Components are attached to game objects to give them functionality. – Components are useful only when they are attached to a game object. – Components that are attached to the same game object affect each other. 2/10/20127
Some Basic Components Mesh filter Mesh renderer Rigidbody Colliders Lights Character controller 2/10/20128
Working in Unity Know what you are working on – Game objects are selectable – You can select the game object in the scene pane, or in the hierarchy pane – Select objects to view their properties (in the inspector pane and the scene pane) For example, selecting the camera shows you the 3D volume that the camera sees. 2/10/20129
Creating Things You can create pre-made game object templates in GameObject->Create Other menu. You can also create empty game objects in GameObject->Create Empty menu. You can populate these game objects with different components to add them various functionality. Let’s make an example. 2/10/201210
Parent-Child Relationship Drag game objects on each other in the hierarchy. Top one is parent, bottom one is child. Child moves with the parent. – E.g., a man sitting in a car. Just moving the car is enough to move the man, the wheels, the doors, etc. together. 2/10/201211
Positioning the Camera A common problem – “I can see my scene fine in the scene pane, but when I run the game it shows it from the stupid camera angle. I want it to look like the scene pane.” Solution – Adjust the view in the scene pane – Select the camera (“Main Camera” from hierarchy) – Choose from the top menu: GameObject -> Align With View – Now the camera sees just like you see the scene. 2/10/201212
Creating the Same Things Over and Over Example: A game with many monsters that act the same way – Create all the details over and over again for each monster? – Example 2/10/201213
Solution: Prefabs Prefabs are an easy way to create copies of complicated game elements Make sure your object (monster) has a single parent GameObject. In Project pane, Create->Prefab – Initially it’s gray (empty) – Drag your object (monster) to the prefab in the Project pane Now it became blue. – Now you can create copies of this as you like. To create a new instance of this Prefab, you need to drag it from the Project pane. You can drag it either to the scene view or the hierarchy pane. 2/10/201214
Prefabs Let You Correct Your Mistakes When you edit the Prefab (select the prefab, change values in the inspector), the changes are reflected in all of its instances. When you edit one of the instances of the prefab (select the instance, change values in the inspector), the changed values appear in bold. This means that those values are special for that instance and are different than the prefab. – If you change your mind and cancel these special changes, you can click the Revert button on top of the inspector – If you want to apply these changes to the Prefab (and all other instances of it), you can click the Apply button on top of the inspector Removing game objects from the Instance’s hierarchy breaks the prefab connection. However, you can re-enable this connection by hitting the Apply button as before. This will remove that object from the Prefab (and all other instances of it) as well. 2/10/201215
Importing Assets from Blender Just drag them to the Unity Project! – Need to do some adjustments for materials and textures 2/10/201216
TODO: Projects On Friday, we will you feedback on the game ideas that you have submitted. We may choose one of them, or give you the option to choose among them. You will revise your chosen game idea according to our feedback. You will improve it further yourself. You will present your game idea as a group next week. You have the option to use any audio- visual aid for your presentation. 2/10/201217
TODO: Homework 3 Create a monster for your maze. – You can use Blender or you can combine Unity primitives (cube, sphere, etc). Choose a place in your maze that you don’t want the player to go to. Make it so that when the player approaches that area, the monster appears in the direction that the player should not go. Once this is working, create one prefab that contains everything necessary for the monster to appear. Name the prefab “Monster”. Create at least two more instantiations of the prefab that work similarly. Dragging the prefab and adjusting its position/orientation should be sufficient. We will see if your prefab works that way. Get Özkan to grade it – (NOTE THE ADDRES CHANGE!) – Subject (paste this): SE 320 Homework 3 – What to send: Assets -> Export package File -> Build Settings -> Web player -> Build 2/10/ When he gets here 2. monster appears 3. so, player chooses to go this way instead