Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

This tutorial aims to explain the process of replacing a player character from the Isometric Pathfinding Template C++ template project with another animated model.

Info

Please be advised that GameSDK is NOT used for this tutorial. It is based on the templates that are provided with the Engine, so create a new project using the Isometric Pathfinding template.

Tip

If you prefer to watch a video tutorial rather than read a written one, check out the video tutorial at the bottom of this page.

Note

This tutorial can be used as a base for other templates, but these don't work exactly the same as the Isometric Pathfinding template. Please be careful when attempting this.

Tools Used

  • Character Tool
  • Mannequin Editor
  • Microsoft Visual Studio® (a free Community version is available)
  • Any .xml editor, like Notepad++

Files

Download the following file and extract anywhere:

DeerTutorial.zip

This is just an example asset. It is of course possible to use other .fbx characters.

Importing the Character Model

  1. Open the Character Tool and drag & drop the deer.fbx file into its viewport:
  2. Save it under objects/characters/

    Tip

    Importing will create several different assets related to this character model, so it is recommended to create a new folder inside objects/characters, e.g. objects/characters/deer.

Importing and Assigning the Texture

The .zip file also contains a texture file, deer_texture.tif. To assign this to the deer model:

  1. Drag the deer_texture.tif into the same folder in the Asset Browser.

  2. Double click the deer material and in the Material Editor that just opened, under Texture Maps, remove the Normal.
  3. Change the Diffuse to the deer_texture in the deer folder.
  4. File -> Save and close the Material Editor.

Importing and Adjusting Animations

When looking under Animations, it will become clear that the one animation that came with this model (i.e. Take 001) is actually made up of three different animations: an idle animation, a walking animation and a running animation.

First, it is important to know which frames represent which animation. To find this out, go to Character Tool -> Playback panel and change Seconds to Frames:

Changing seconds to frames

Check when the animations start and which frame is the last of each animation. Write these frames down for later use.

Info

The first frame is the default pose and therefore not part of an animation. Make sure to skip this frame and start the first animation on frame 1.


To separate the animations:

  1. Open the Animation importer by either:
    In the Character Tool going to File -> Import FBX -> Animation or;
    In the main Sandbox UI, going to Tools -> FBX Import -> Animation.
  2. Drag & drop the deer.fbx file into the viewport of the Animation importer.
    In the panel on the left, the one long animation has now appeared:


    Initial animation clip
    To separate this animation into an idle, walking and running animation, all that needs to be done is to create 3 animation clips. Adjust the animation clip that is already available to only contain the idle animation by setting the start and end frame numbers appropriately. Use the frames written down earlier, for example, the idle animation starting from frame 1 and ending on frame 616.
  3. Rename the animation clip from Take 001 to something relevant, like deer_idle.

    Info
    title Optional

    Click Preview this to test the animation.

  4. Click the small dropdown button next to Animation clips and choose Add.
  5. Add the walking animation the same way.
  6. The run animation will not be used in this example, so just choose File -> Save and exit the Animation importer.

Adding the Skeleton

To add the skeleton of the deer, either the Character Tool can be used, or the skeletonlist.xml file can be edited.

In the Character Tool

  1. In the Assets pane on the left, expand Compression (Animations/).

    Skeleton List location
  2. Select Skeleton List.
  3. Go to Properties -> Aliases, click on the small dropdown button and choose Add.


    Adding a skeleton
  4. Use the browse button on the right of the newly created Alias to search for /Objects/Characters/<folder chosen above>/deer.chr. Click Open.

In Skeletonlist.xml

  1. In the Windows File Explorer, open <Project Folder>/Assets/Animations/skeletonlist.xml.
  2. Copy and paste the line for the existing skeleton onto the following line and replace the name and path to match your deer skeleton, e.g.
    <Skeleton name="deer" file="Objects/Characters/deer/deer.chr"/>.

    Info

    It is advised to name the skeleton the same as the name of the file that was imported earlier, in this case deer.

  3. Choose File -> Save and close the Character Tool.

Changing the Third-Person Model to the Deer Model

Now that the model and all its associated parts (skeleton, texture etc.) have been imported into the Sandbox, the template source code needs to be modified to load the new deer model instead.

  1. Close the Sandbox.
  2. Go to the root folder of the project, right click on game.cryproject and choose Generate solution.
  3. A new Solutions folder will appear. Open this folder and the following subfolder (win64 if you've generated a solution for 64-bit Windows) and open game.sln.
  4. In the Solution Explorer on the right, search for player.cpp and open it:


    Looking for player.cpp
  5. Look for line 25, which contains m_pAnimationComponent->SetCharacterFile and replace the thirdperson.cdf with the deer.cdf, including its path. The line would then read something similar to: 
    m_pAnimationComponent->SetCharacterFile("Objects/Characters/deer/deer.cdf");

    Info

    The line number mentioned here may vary between Engine versions.

  6. Now compile the whole build by going to Build-> Build Solution
  7. Close Visual Studio.
  8. Open Assets/Animations/Mannequin/Preview/Player.xml.
  9. Change the model at the end of line 4 and 5 to your deer.cdf, including its path (like in step 5).

  10. Save and close.

Changing the Animations

The character still needs to be set up to use the new animations that were imported earlier, because the animations from the third-person template (Motus character) are incompatible with the new deer skeleton.

  1. Open Sandbox again and open the Mannequin Editor (Tools -> Animation -> Mannequin Editor).
  2. Go to File -> Load Preview Setup and choose player.xml.
  3. Click the Fragments tab in the bottom left corner.
  4. In the Fragments tree in the top left, expand the Idle -> Walk animation and double-click Option 1:

    Finding the Walk animation

  5. Now, in the bottom of the Fragment Editor on the right, click the bar under ThirdPerson(Thirdperson): Walk:

    Walk animation in Fragment Editor
  6. To the right in the Anim Clip Properties, click the field next to Animation and change this to the deer_walk animation:

    Changing animation clip

    Info
    titleOptional
    The FirstPerson animation is not necessary, because this is an isometric game example, so if desired, the FirstPerson(FirstPerson): Walk animation that was not changed, can be deleted. It will not impact the game if this is not deleted.
  7. Do the same for Idle -> Default -> Option 1, but change this to the deer_idle animation.
  8. Choose File -> Save Changes and close the Mannequin Editor.

Testing the Character

Now press Ctrl + G to test the deer in the template level. Clicking anywhere in the level or on the ramp should make the deer walk there.

Info

It is advised to name the skeleton the same as the name of the file we imported, in this case deer.

Example Level

An example level can be found on the Marketplace that combines the results from this tutorial and the next one. You can find it on the Marketplace.

Anchor
VidTutDeer1
VidTutDeer1
Video Tutorial

Widget Connector
width600
urlhttps://www.youtube.com/watch?v=xP1NpW_iT_A&index=2&list=PLpCgy91Y5vMtcsQg4ZnuALZgIICvj9THn&t=0s
height400

On This Page

Table of Contents
maxLevel2
excludeOn This Page

Related Pages

Tutorial - Adding an Animation in Mannequin