• 沒有找到結果。

Tutorial Three: Build a player character

在文檔中 Amazon Lumberyard (頁 84-98)

In this tutorial, you will build a player character from various components and create a slice for your player character. You will also learn about Lumberyard’s asset pipeline.

TipIf you like, you can follow this chapter in video (2:48 minutes) form:

Characters

Begin this tutorial either with the level you created in the section called “Entities” (p. 71), or by

opening ch02_barnyard_final from the Levels directory of the WelcomeGuideTutorials project. To open a level in Lumberyard, choose Open Level… from the File menu in the main menu bar.

1. This tutorial is written for the default Lumberyard Editor layout, so make sure this is the layout that you’re using. To set the layout, access the menu bar and select View, Layouts, and choose Default Layout.

2. Create a player character entity. In Asset Browser on the left side of the editor, find

ch03_chicken_start.fbx in the Actors directory. This asset was created in a third-party application and saved as a .fbx file for import into Lumberyard.

Characters

3. Click and drag ch03_chicken_start.fbx into the Perspective pane. Drop it somewhere in front of the feed_locker entity. This creates an entity for the chicken player character from the ch03_chicken_start.actor asset.

Characters

4. Press the Z key to focus on the chicken entity, or use the mouse and keyboard navigation controls to get a good view of the chicken asset.

5. Modify the FBX Settings for the chicken asset to import her mohawk as a cloth object. Models, rigged actors, and animations created in third-party applications are imported into Lumberyard through .fbx files. The chicken .fbx file contains a mesh asset for the chicken’s mohawk that has not been imported. You can add the mohawk to the chicken’s Actor group in FBX Settings to import it, and add a modifier that will add cloth data to the mohawk so that it behaves like a cloth object at run-time.

a. Right-click ch03_chicken_start.fbx in Asset Browser and choose Edit Settings to view the FBX Settings for the chicken.

FBX Settings should open to the Actors tab displaying one Actor group. This group will output one actor asset from the .fbx. The .actor asset contains meshes and a skeleton that are selected in the actor group. The actor group is mostly set up. You must make a couple of edits to import the chicken’s mohawk as a cloth object.

Characters

b. In the ch03_chicken_start actor group, choose the Hierarchy button to the right of Select base meshes.

c. To import the mohawk mesh, in the Select nodes window, choose chicken_mohawk from the list to add the mohawk mesh to the mesh group. Choose the Select button to close the window.

Characters

d. To add cloth data to the mohawk, in FBX Settings choose Add Modifier and select Cloth from the modifier list.

Characters

e. In the cloth modifier, for Select Cloth Mesh, choose RootNode.chicken.chicken_mohawk to add the chicken’s mohawk as a cloth object.

f. In the cloth modifier, for Cloth Inverse Masses choose Cd from the list to use chicken_mohawk’s vertex color stream to set the mass values for the cloth object. The vertex colors applied to the chicken’s mohawk were pre-painted in a 3rd-party application. Mass will be generated per vertex on the mohawk based on the red value contained in the Cd vertex color stream. for more information on Cloth, see Cloth Simulation.

Characters

g. Choose Update at the bottom of the FBX Settings window.

h. In the Progress window, choose Ok. The window closes and the .fbx file is quickly processed with the new settings. The mohawk mesh appears in Perspective on the chicken entity.

Characters

i. Close the FBX Settings window.

Characters

NoteWhen you close the FBX Settings window, you might see a window stating there are unsaved changes even though the changes have been automatically saved. This is a known issue. Choose Discard to close the FBX Settings tool.

6. In Entity Outliner, click the ch03_chicken_start entity to select it.

7. In Entity Inspector on the right of the editor, rename the entity. Click in the field next to Name and enter player_chicken.

8. The mohawk has been imported and has cloth data applied, but to get the mohawk to simulate as a cloth object at run-time, you need to add a Cloth component to the player_chicken entity. In Entity Inspector, choose Add Component to open the component list. Enter cl in the search field to filter the list by name and choose Cloth from the filtered results to add a Cloth component.

Characters

9. In the Cloth component that has been added to the entity, for Mesh node, choose chicken_mohawk from the list.

Characters

10.Click the Simulate button in the bottom toolbar of the Perspective pane, or press Control + P to test the cloth simulation. The chicken’s mohawk should flop over like cloth. Press Control + P to exit simulation mode.

Characters

11.Create a slice from the player_chicken entity. Right-click the player_chicken entity in Entity Outliner, and choose Create slice…. Save the entity as a .slice in the Slices directory as player_chicken.slice. Slices are reusable and can be instanced, each instance having unique property settings. You can create complex slices using collections of simple entities.

Characters

For extra credit, play with the settings in the Cloth component and test the simulation in Perspective to fine-tune the mohawk behavior. See the Cloth component documentation for more info. Save your changes to the player_chicken.slice.

The cloth simulation requires collision primitives to prevent the mohawk cloth mesh from penetrating the chicken geometry when simulated. You can see how these colliders are set up in Animation Editor.

1. Open Animation Editor from the Tools menu.

2. Open the chicken actor from the File menu in Animation Editor.

3. Enable the Physics layout from the Layouts menu in Animation Editor.

PhysX

You will see spheres and capsules attached to the chicken’s skeleton. These are the cloth colliders. You can locate their nodes in the Skeleton Outliner by the shirt icon to the right of the node name. Like the Cloth modifier you added in FBX Settings, these colliders and their properties are saved in the .assetinfo file so that Asset Processor can include them in the runtime asset.

When you’re ready, try the section called “PhysX” (p. 93).

在文檔中 Amazon Lumberyard (頁 84-98)