Tutorial: Introduction to Components, and Mesh Component. 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. Tools>Entity Outliner 3. Open the entity Inspector. Tools>Entity Inspector Your viewport should look like this with the Entity Inspector on the right and the Entity Outliner on the right.
4. Right click in the viewport or the entity outliner and choose “Create new component entity”.
5. 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. In the Entity Inspector Click the Add Component button.
2. Navigate to the rendering folder.
3. Select Static Mesh. For this tutorial we will be using the Primitive Cube. In the Entity Inspector, click on the … button next to the static asset field of the static 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. 4.
Navigate to the objects>primitives folder and choose the box_1x1.cgf asset. And click Open
5. 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 asset browser from the tools menu. Tools>Asset Browser (preview)
2. Navigate to dev>SampleProjects>Objects>Primitives>box_1x1.cgf
3. Left click on the box_1x1.cgf 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.
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.