Documentation/Tutorials/Main Character Replacement

From NeoAxis 3D Engine Wiki

Jump to: navigation, search
Go to higher level

Contents

Introduction

In this tutorial, we will learn how to create character. At the moment, it's possible to create two kinds of characters - an AI controlled character and a player character.

In the first part of the tutorial, we will learn to create a character from scratch. In the second part, we will create a new character by copying and modifying an existing one. In the last part, we will see how to use the previously created type in a map.

CreatingCharacter 022.jpg

Creating the Object Type

To start with, we will create a player character. In addition, instructions for creating an AI controlled character will be given in footnotes. First of all prepare resources required for the character. There are:

  • 3D-model (.mesh),
  • skeleton (.skeleton),
  • material (.highMaterial),
  • animation tree (.animationTree),
  • textures (.dds),
  • sounds (.ogg),
  • additional content, weapon (.type).

Run the Resource Editor.

Firt of all, create the folder for our new type. Simply right click on the Data\Types\Units folder and select New -> Folder in the context menu.

CreatingCharacter 001.jpg

Name the folder: MyCharacter. We will now put our resources into the new folder. For this example, we will use pre existing resources that comes with the Neoaxis SDK. From the Data\Types\Units\Zombie directory, copy the following files:

  • Zombie.animationTree,
  • Zombie.highMaterial,
  • Zombie.mesh,
  • Zombie.skeleton,
  • Zombie1.dds.

Select the files, right click and select Copy in the context menu. To copy them in the MyCharacter folder, just right click on it and select Paste.

CreatingCharacter 002.jpg

Now let's edit our resouces. First of all, rename them to MyCharacter. Right click on an asset and select Rename in the context menu.

CreatingCharacter 003.jpg

To edit the MyCharacter.highMaterial material, select it in the folder and click the Edit button in the main tolbar. You can also just double click on the asset in the tree view to enter edit mode.


In the Properties window, select the Diffuse1Map property and press the "..." button in front of it. In the popup window, select the MyCharacter.dds texture from the Data\Types\Units\MyCharacter folder and click OK.

CreatingCharacter 004.jpg

To save the changes, press the Save button in the main toolbar.

Now open MyCharacter.mesh to edit. In the property's window press the button "..." in front of computer field SkeletonName. In the appeared window select a file MyCharacter.skeleton from the folder Data\Types\Units\MyCharacter and click the button OK. After that click the button "..." in the property MaterialName of the submesh 0. In the appeared window select the file MyCharacter.highMaterial from our folder and click the button OK.

CreatingCharacter 005.jpg

Save changes by clicking the button Save in the main toollbar.

We can now start to create a character type (.type file).

Right click on the MyCharacter folder and select New -> Entity Type in the context menu.

CreatingCharacter 006.jpg

In the popup window, name the type — MyCharacter, class — PlayerCharacter and click the Next button. To create an AI character, you would need to choose the GameCharacter class.

CreatingCharacter 007.jpg

The type file is a resources container. You will now need to add resources to the type.

Enter edit mode for our newly created type file, select it and click Edit button in the main toolbar.

Start by attaching the character 3D-model. In the Objects window, right click on the root object and select Attach Object -> 3D Model.

CreatingCharacter 008.jpg

In the popup window, select the MyCharacter.mesh file from out folder and press the OK button.

CreatingCharacter 009.jpg

You can now see the character model in the type file.

CreatingCharacter 010.jpg

Now we will move the character a bit, so the physical model will match the character mesh dimensions. By default, a capsule is used as physical model. This physical model is used to handle the collisions of the character with the environment. To see the character's physical model, check the Show Physics property in the property window. Align the character model and the capsule. To do this, select the attached 3D model in the object window and type the following values in the Position field "0 0 -1.15". You can also move the mesh using the move tool located in the top toolbar.

CreatingCharacter 011.jpg

You now need to take care of the animation of the character. Neoaxis uses a .animationTree file as a description of the available animations. Add the animations tree file to the new type. To do this, click on the "..." button next to the AnimationTree field.

CreatingCharacter 012.jpg

In the popup window, choose the MyCharacter.animationTree file and click on OK.

CreatingCharacter 013.jpg

We will now change a few parameters of our character. For this, select the MyCharacter type (root object) in the object window.

CreatingCharacter 014.jpg

In the Character section, we will setup the properties that affects the character's movement:

  • FlyControlForce = 49000 (power of the force used for flight control)
  • FlyControlMaxSpeed = 3 (maximum speed in flight)
  • WalkForce = 280000 (force applied when walking)
  • WalkForwardMaxSpeed = 2 (maximum speed when walking)

In the Dynamic group, specify the following parameters:

  • HealthMax = 40 (maximum health points)
  • Substance = Flesh substance - flesh)
  • TargetPriority = 1 (priority target for the enemy)

In the Entity group:

  • CreatableInMapEditor = True Allows the creation in the map editor)
  • NetworkType = Synchronized (network type - synchronized)

In the group GameCharacter:

  • OptimalAttackDistanceRange = 0 1 (optimal distance range for attack)

Now, in the Unit group, click on the "..." button next to the InitialAI field (artificial intelligence, defining behaviors), select DefaultGameCharacterAI (artificial intelligence character default) and click OK.

CreatingCharacter 015.jpg

In the same group, Unit, enter the following values:

  • FPSCameraOffset = 0.3 0 0.7 (shift the camera in first person view)
  • ViewRadius = 40 (sight range)
CreatingCharacter 016.jpg

Finally, save the file. To do this, press the button with the floppy disk icon in the main panel.

The configuration of the character is complete and we can use it on one of the maps.

Create a New Object Type by Copying

Due to the fact that different characters types often have many common properties, creating a new character based on an existing one is the fastest way to proceed.

To copy a character type, copy in a new folder the "'.type"' you want to copy as well as all the necessary resources.

CreatingCharacter 017.jpg

After that, rename the type file, and open it for editing. You can also edit the files manually in a text editor.

Now, the configuration of your character will be done the same way as described in the previous section. We have to delete the unecessary meshe(s), then add or replace the ressources with the ones we want to use ( mesh, animations tree, AI etc.) You also need to configure the various properties of the character.

It is important to remember that the class of a type cannot be changed. Therefore, the types of the player controlled character must be created using the "'PlayerCharacter"' class whereas AI controller characters need to use the "'GameCharacter"' class.

Replacing the Player Character on a Map

In order to test our newly created character, run the Map Editor and open any map. For Example, VillageDemo.

In the Objects window, select the root object (Map).

CreatingCharacter 018.jpg

In the Properties window, select the PlayerUnitType property and press the "..." button.

CreatingCharacter 019.jpg

In the popup window, select the MyCharacter.type we have created. It's located in the Data\Types\Units\MyCharacter folder.

CreatingCharacter 020.jpg

Press the button with the floppy disk icon to save the map. Then run the simulation by clicking on the Run button in the main toolbar.

CreatingCharacter 021.jpg

You can now control your new character! To ensure that the character has really changed, change the camera view to 3rd person (key F7).

CreatingCharacter 022.jpg