To turn the character you imported in the previous tutorial into your playable character, you will need to do make some small adjustments in the code.
- Visual Studio (or the Visual Studio Community version)
Generating a Solution
To get access to the code, do the following:
- Go to your project folder.
- Right click on the .cryproject file.
- Choose Generate Solution (this may take a while).
Defining the Playable Character
- When you have generated a solution, open the solutions/win64 folder and double click the Game.sln file.
- In this file, go to Components/Player.cpp:
- Look for
m_pAnimationComponent → SetCharacterFile(you can use CTRL + F for this) and change the path and file name to that of the imported character file.
Build your project again by going to Build → Build Solution (or Build Game) in the main menu.
It is recommended to close CRYENGINE while building a solution.
Save and close Visual Studio.
Changing the Preview File
- In your project folder, navigate to the Assets/Animations/Mannequin/Preview folder.
- Open the Player.xml file with an XML editor, like Notepad or Notepad++.
- In the line that starts with
<contextData name="ThirdPerson", change path and file name you used above, in step 3 of Defining the Player Character.
- Save and close the file.
Viewing Your Character in a Level
- Create a level or open an existing one.
- Drag and drop your character file from the Asset Browser into the level. It should appear in T-pose.
Now that you have successfully changed the player character, all you need to do is assign the right animations to it.
- Open the Mannequin Editor and go to File → Load Preview Setup...
- Open the Player.xml file.
- In the Fragments panel, expand the Walk animation and double click on <default>/Option 1:
Walk animation in Fragments panel
- In the Fragment Editor, select the ThirdPerson(ThirdPerson) timeline:
- Now click the name of the Animation in the Anim Clip Properties to the right, click the browse button (
Changing the animation )and choose your walk animation:
Repeat steps 3-5 for the <default>/Idle animation.
If you have more than one Idle animation, and you want the engine to choose between those randomly for some variation, you can add these by selecting Idle/<default> and clicking the New button:
Adding more Idle animations
This will add another "Option n" fragment, to which you can assign another animation.
Keep in mind though that you may have to add a Layer on the timeline first by right clicking on the ThirdPerson(ThirdPerson) fragment in the Fragment Editor and choosing Add Layer → AnimLayer.
- Save your changes by going to File → Save Changes...
You may have noticed that when your character stands still and you move the mouse, it jumps back to its T-pose. This is because you have not assigned a Rotate animation yet.