Tutorial: How to Work with Component Entities

Report 2 Downloads 108 Views
Tutorial: How to Work with Component Entities This tutorial walks you through the steps to make a component entity, including assigning components, setting component properties, and moving, rotating and scaling the entity. At the end of the tutorial you will have a basic understanding of how to work with component entities. You will learn how to do the following:    

Create a component entity Add a static mesh component to the entity Assign a mesh to the static mesh component Use the asset browser to create a component entity from a mesh asset

Prerequisites While it is not entirely necessary to complete any prerequisites for this tutorial, we do suggest you go through the getting started series so you have a basic understanding of the Lumberyard UI, how to transform objects, and how to navigate in the engine. The recommended getting started tutorials are:   

Getting Started in Lumberyard. Creating a level Lumberyard Objects

Step 1: Create a Component Entity The first step in the tutorial is to create a component entity. To Create a Component Entity 1. Create a new level, the default settings are fine for this tutorial. 2. Open the entity outliner. View>Open View Pane>Entity Outliner

3. Right click in the viewport or the entity outliner and choose “Create Component Entity”.

4. Observe a transform handle is displayed in the viewport and the entity outliner.

Step 2: Add a Static Mesh Component to the Entity After you create an entity, you will want to add components to it. Components are basic building blocks that define a game object. You can add lights, scripts, particle effects, animation controls and many other types of component to an entity. For now, we’re going to add a mesh component. To Add a Static Mesh Component to the Entity 1. With the entity you made in step 1 selected, open the entity inspector.

2. Click the Add Component button.

3. Navigate to the rendering folder.

4. Select Static Mesh. For this tutorial we will be using the Primitive Cube. In the Entity Inspector, click on the … button next to the asset field of the Mesh Component.

After you add a component, you will want to customize it to suit your project’s needs. Each component comes with a set of properties to define the parameters or behaviors of that component. We’re going to need to assign a mesh to the static mesh property to make the mesh component work. 5.

Navigate to the objects>primitives folder and choose the box_1x1.cgf asset. And click Open

6. You have now added a mesh component to your entity.

Quick Tip (Alternatively, you can drag and drop mesh assets from the asset browser to the mesh property field.) Now that you have a static Mesh attached to the Component Entity, you can move scale and rotate this like any other object you bring into Lumberyard. If you need more detail on the way you transform objects in Lumberyard click here.

Step 3: Create a Component Entity from a Mesh Asset You’ve learned the basics of creating entities and adding components to them. This last step will show you how to add a game asset to your scene directly from the asset browser. To Create a Component Entity from a Mesh Asset 1. Open the file browser from the view menu. View>Open View Pane>File Browser

2. Navigate to objects>primitives>box_1x1.cgf

3. Left click on the cube or another primitive shape and drag the asset into your viewport.

4. Observe that the new entity has a static mesh component built into it already and the mesh field has been assigned to the mesh asset you dragged into the scene.

Congratulations! You have successfully created component entities in two different ways.

Related Tasks and Tutorials Now that you have learned the basics of creating entities and assigning components, see what else you can add to your game:  

Create a Gem with code Working with Slices

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.