Lesson 6 Advanced Camera Positioning using Dummy Objects Pre-Requisites: Lesson 5 Topics: 1. Events (let arrow keys move…) 2. Dummy Objects Introduction: In our last session we started making our racing game and set the camera to follow the car from a third person view. In this session we will add the ability to switch to a first person (driver’s perspective) view and a side view of the car. We will use events to change the view when the player presses a number key. Using Dummy Objects: We will use dummy objects to remember where the camera should move to when the player selects a new view. In Alice a dummy object is a special object that we can see when the world is being edited but it does not show up when it is playing. These objects are great for remembering a location to move to. Let’s create dummy objects to remember three camera positions. Drop a dummy object at the camera’s current position: Click the green “ADD OBJECTS” button. Click the “more controls >>” button. Finally, click the “drop dummy at camera” button. This sequence just dropped a dummy object to remember the camera’s current position. We should name the dummy object something that will remind us of its use. Rename “dummy” to worldview: In the object tree on the left side of your screen find the item for “Dummy Objects”. This is a grouping of like objects. Click the “+” symbol next to it. You will see two entries. Click the right mouse button on “dummy” then pick “rename”. Now type “worldView" and press <ENTER>. In order to switch views while the world is playing we need to be able to tell Alice to move the camera to a new location. We will find those locations now and then drop dummy objects to remember them. Move the camera to the driver’s view: Find “camera” in the object tree. Right click on “camera” and choose “methods”->”camera set point of view to …” ->”convertibleCorvette”->”the entire convertibleCorvette”. This will instantly move the camera to inside the corvette but the camera is too low. Use the purple arrow buttons raise the camera, tilt it down and move it back until it can see part of the hood of the car and the road in front. Like my picture. Drop a dummy at the camera: Click the “drop dummy at camera” button on the right side of your screen. Rename the new dummy: In the object tree on the left side of the screen rename the “dummy” object to “driverView”. Move the camera to a side view of the car: Click the right mouse button on “camera” in the object tree. Pick “methods”->”camera get a good look at”-> ”convertibleCorvette”->”the entire convertibleCorvette”. Now use the purple arrows to move the camera so that you see the car from the side. Your view should look similar to mine below. Drop a dummy at the camera: Click the “drop dummy at camera” button on the right side of your screen. Rename the new dummy: In the object tree on the left side of the screen rename the “dummy” object to “sideView”. We now have dummy objects in three places that we can jump to during the game. However, the dummy objects will never move, even if the car moves. So if we jump to the side view after the car moves we will be looking where the car used to be! We will use the vehicle property to fix this. Set the vehicle of driverView and sideView to convertibleCorvette: Click on “driverView” in the object tree with your left mouse button. Click on the “properties” tab just below the object tree. Click on the “world” dropdown next to “vehicle”. Pick ”convertibleCorvette”->”the entire convertibleCorvette”. Click on “sideView” in the object tree and then set its vehicle to the car using the same procedure. The last piece that we need to make our world work is moving the camera when the player pushes a button. We will create 3 new events to move the camera. These events will run when the user presses the 1,2 or 3 keys on the keyboard. For example, when the user presses the 1 key the event will move the camera to the driver’s view. Create 3 new events: Click the green “DONE” button. Click the “Create new event” button near the top right corner of your screen. Pick “When a key is typed”. Do this 2 more times. The new events were added to the end of the list so scroll down to the bottom of the event list. Set the 1 key event: Find one of the 3 events that say “When any key is typed, do Nothing”. Click on the words “any key”. Go to “numbers” and pick “1”. Now click on the “camera” in the object tree and drag it on to “Nothing” and then release the mouse button. Pick “camera set point of view to”-> “Dummy Objects” -> “driverView”. Set the 2 key event: Find one of the 2 events that say “When any key is typed, do Nothing”. Click on the words “any key”. Go to “numbers” and pick “2”. Now click on the “camera” in the object tree and drag it on to “Nothing” and then release the mouse button. Pick “camera set point of view to”-> “Dummy Objects” -> “sideView”. Set the 1 key event: Find the last event that says “When any key is typed, do Nothing”. Click on the words “any key”. Go to “numbers” and pick “3”. Now click on the “camera” in the object tree and drag it on to “Nothing” and then release the mouse button. Pick “camera set point of view to”-> “Dummy Objects” -> “carView”.