Characters wouldn't be very interesting without animations! In this recipe, we will cover the basic task of animating a character and exporting that animation to be played later in Sandbox.
There are four important steps involved in preparing and animating your character from CryENGINE 3:
Use the SDK sample asset character to start this recipe, as the character creation process has already been discussed in previous sections.
First, let's open the character in the character editor:
Objects/Characters/neutral_male/sdk_character_male_v2.cdf
. It is important to verify that your character is working in the engine before we can begin with animation. animations.cba
file, which can be opened in any text editor. You will find this file in the game/animations
folder.<AnimationDefinition> <!--the reference model--> <Model File="/../Objects/Characters/neutral_male/skeleton_character.chr"/> <!--the path with ALL animation we can use on this model--> <Animation Path="human_male"/> <!--for all animations use compression level 1--> <COMPRESSION value="2"/> <RotEpsilon value="0.0000001" /> <PosEpsilon value="0.0000001" /> <Database Path="human_male/human_male.dba"/> <!--for all animations need to detect footplants--> <FOOTPLANTS value="NO"/> <!--we apply the Locomotion_Locator modification just on BIP-files. Aliens, vehicles and weapons don't need it. --> <LOCOMOTION_LOCATOR value="YES"/> <!--we apply different modifications to the weapons . Human and Aliens don't need it. --> <!--a list of animation that need special handling--> <SpecialAnimsList> <!-- AIMPOSES COMMON --> <Animation APath="Aim" footplants="NO" compression="0" autocompression="0" SkipSaveToDatabase="1" /> <Animation APath="vehicle" footplants="NO"/> </SpecialAnimsList> </AnimationDefinition>
Having verified that this character is already present in the .cba
, we can begin animating. Should you be making a custom character, ensure your character is registered in the .cba
before animation begins. Let's create a simple arm waving animation:
skeleton_character
has been added to the export nodes list. .caf
file. animations.cba
for the character. In this case, save it as cookbook_wave.caf
under the Animations/human_male
folder. .chrparams
. .chrparams
file in any text editor and locate the animation list. It is defined by <AnimationList>
:<AnimationList> <Animation name="#filepath" path="animationshuman_male"/> <Animation name="$AnimEventDatabase" path="animationshuman_malehuman_male.animevents"/> <Comment value="$Include = objectscharactershumanGlobalHuman.chrparams"/> Insert a new entry for our animation below the $Include line as below <AnimationList> <Animation name="#filepath" path="animationshuman_male"/> <Animation name="$AnimEventDatabase" path="animationshuman_malehuman_male.animevents"/> <Comment value="$Include = objectscharactershumanGlobalHuman.chrparams"/> <Animation name="Custom_cookbook_wave"path="cookbook_wave.caf"
.chrparams
file, open Sandbox and then open the character editor. Objects/Characters/neutral_male/sdk_character_male_v2.cdf
. cookbook_wave
animation.When a character is loaded by the engine, it checks for a .chrparams
file that defines a list of valid animations for the particular character. These animations then become accessible through code, cut scenes, and the character editor to be played back.
In this example, we dealt with .caf
animation data that is created by exporting the animation range from 3ds. Upon export the Resource Compiler is invoked and a certain amount of compression and optimization is applied to the animation to make it ready for real time playback.
You may want more information on the compression of animations or how to expedite the character animation process by wildcarding animation names within the .chrparams
file.
You may have animations that are jerky or jittering. This can be caused by the original animation asset and in some cases, it can be caused by aggressive compression applied to the animation.cba
.
The value to control compression is seen in a character's definition in the .cba
as the line: <COMPRESSION value="2"/>
.
Change this value to a lower number to compress the animation less aggressively.
Wildcarding the animation names within the .chrparams
file can be carried out as follows:
.chrparams
file, line-by-line, can take an unacceptable amount of time and can lead to very big .chrparams
files.*
) to represent the filename. Using the asterisk in the in-game name will replace it with the part of the actual filename that is wildcarded.For example:
<Animation name="coop_*" path="coopcoop_*.caf"/>.
coop
that starts with the word coop and has the extension .caf
. coop_
and then follows the part of the filename that comes after coop
(which will be removed from the name). kickroundhouse.caf
would be mapped to coop_roundhouse.caf
. .chrparams
file each time.A useful entity for testing animations is the animobject entity found under Entities | physics | animobject.
Once placed in a level, you can assign a model and then enter the string of the in-game animation name.
A good technique is to add this animobject to a flow graph and assign the animation to it using the Animation:PlayAnimation flow graph node.
18.216.255.250