Tutorial: How to Add a Camera to Your Scene

Report 1 Downloads 248 Views
Tutorial: How to Add a Camera to Your Scene Hello, this tutorial will walk you through the steps to add a simple camera to your scene, including activating game mode and managing parent/child relationships. At the end of the tutorial you will know how to setup a static camera for your scenes. You will learn how to do the following: • • • •

Create an entity Add a camera component to an entity Activate game mode Manage parent/child relationships

Prerequisites We suggest you read through the following tutorial before starting this one: • •

Getting Started 2 – Creating a Level Component Basics 1 – Mesh Components

Step 1: Setup Your Scene Open a new Level and you can keep the terrain size, and the texture size set to the defaults. Now we are ready to start playing with cameras. The first step is to add an object in your scene for the camera to look at. I will be using the getting started asset called box_1x1.cgf. To fine the box_1x1.cgf asset 1. Open the asset browser Tools> Asset Browser (preview)

2. Drag the box_1x1.cgf asset into the view pane. dev>SamplesProject>Objects>primitives>box_1x1.cgf

You have now added an asset to the scene that your camera can view.

Step 2: Create a Camera Entity After you have added an asset to look at, we will need to create another entity to attach our camera to. Something important to understand is that the cameras lens points down the Y axis. This is easiest to see when you use the Helper tool. To create a camera entity 1. Right click in the viewport 2. Choose Create new component entity

3. If the Entity Inspector isn’t opened, open it now Tools> Entity Inspector 4. Name this new entity: camera, the box_1x1 entity should have auto set up its name to, you guessed it, box_1x1. 5. With the camera entity selected, click the Add Component button in the Entity Inspector

6. Navigate to the Camera component and add it to your entity, Game> Camera

7. Make sure the Helper tool is turned on

8. Use the rotate tool to point the Y axis toward the box_1x1 entity.

You have now created a camera, and pointed it at your asset.

Step 3: Enter Game Mode After you have set up your camera and pointed it at the asset you want to view, the next step is to go into game mode to see if your camera is able to view the asset. To enter game mode 1. Press ctrl+g on your keyboard to enter game mode. 2. You will not be able to pan around in game mode, but you should see something like this in the Viewport.

3. Press the esc key to exit game mode Now that you have entered and exited Game Mode, you can reposition your camera to get a better view, and enter game mode again to see the results. You may need to play with this a few times to get the asset perfectly situated in the view pane to your liking.

Step 4: Managing Parent/Child Relationships Best practices dictate that you organize your game assets so you can quickly fide assets in your level. One good way of doing this is using the Parent/Child relationship. We also cover this step in detail in the tutorial Component basics – Working with Slices To parent your camera to the asset. 1. If it’s not already open, open the Entity Outliner. Tools> Entity Outliner 2. Drag your camera entity on top of the box_1x1 entity. Notice how the entity hierarchy indents the camera that means the camera is a child of the box_1x1 entity.

Congratulations! You have successfully created a camera and made it a child of another entity to pair the two together. Want to learn more about Lumberyard? Visit the complete Lumberyard Tutorials Page. We’d love to hear from you! Head to our Tutorial Discussion forum to share any feedback you have, including what you do or don’t like about our tutorials or new content you’d like to see in the near future.