Having learned in the previous example how to create, export, and skeleton a character, we will now learn the basics of animating it. For this example, you can use your own custom character created in the previous example or open the example character provided.
ObjectsCharactersagentSDK_Agent.max
.animations.cba
file with any text editor, for example Notepad. You will find this file under the game/animations
folder.In the animations.cba
file, each entry is a character animated within the Free SDK. You will notice that developer comments already exist to explain each of the parameters.
When creating a custom character, it is common practice to copy the definition for a similar character and set the Model File path
, Animation Path
and Database path
to that of your own skeleton.
animations.cba
file (as seen in the example), paying special attention to the Model
, Animation Path
and Database Path
values:<AnimationDefinition> <!--the reference model--> <Model File="/../Objects/Characters/agent/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>
In the previous code snippet, I have left the developer comments intact; however, I have made the adjustments to use the character created in the previous example.
Having now added this character to the .cba
, we can begin animating.
Let's now create a simple, arm-waving animation that will take us through the basics of exporting skeletal animation.
As this is a 3ds Max Biped, you could now apply motion capture data to the Live Deforming Skeleton. You can find such data online or in the example files provided on http://crydev.net. For now, we will assume that such data is not available for the animation we require.
As we want this animation to loop, we must set the last keyframe of our animation to the same position as the first keyframe.
For this example, copy the first keyframe to the twentieth frame.
As discussed earlier, this will automatically add the parent node of the skeleton to the export bones list.
.caf
file.custom_wave.caf
under the Animations/human_male
folder.There is one final step that we must complete before being able to view our character animation in Sandbox's character editor.
We must add this new animation to the characters parameter file or .chrparams
.
.chrparams
file found under GameobjectsCharactersAgentskeleton_character.chrparams
.<AnimationList> <Animation name="$AnimEventDatabase" path="animationshuman_maleevents.animevents"/> <Animation name="$Include" path="animationshuman_malemale.chrparams"/> </AnimationList>
<AnimationList> <Animation name="$AnimEventDatabase" path="animationshuman_maleevents.animevents"/> <Animation name="$Include" path="animationshuman_malemale.chrparams"/> <Animation name="mycustom_wave" path="custom_wave.caf"/> </AnimationList>
Objects/Characters/Agent/Agent.cdf
in the Character Editor within Sandbox.Note that, on the left-hand side of the Character Editor, you can now browse into the newly created mycustom
folder, where you will see the custom_wave animation.
Congratulations! You have created and exported your own animation to the CryENGINE. You can now start animating more complex or more extreme animation as your game might require.
When a character is loaded by the engine, it checks for a .chrparams
file that defines a list of valid animations and other properties, such as IK limits, 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 the .caf
animation data that is created by exporting the animation range from 3ds Max. 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.
Assigning each animation definition in the .chrparams
file, line by line, can take an unacceptable amount of time and lead to very big .chrparams
files.
It is only necessary if the in-game name that is supposed to be assigned to the animation is substantially different than the filename of the .caf
.
Wildcard Mapping uses the asterisk (*) to represent the filename. Using the asterisk in the ingame name will replace it with the part of the actual filename that is wildcarded.
For example:
<Animation name="Custom_*" path="custom_wave_*.caf"/>
This code line will load all the animations from the folder Custom
that start with the words custom_wave
and have the extension .caf
.
Wildcard Mapping can even be used on an entire folder. It requires, however, that these folders are kept clean of old and unused assets to not waste memory.
One important advantage of using wildcards is that, once a folder is mapped, new animations can be quickly added to that folder without the need to add an animation definition in the .chrparams
file each time.
A useful entity for testing animations is the animobject entity found under Entities | Physics | animobject of the entity section in the RollupBar tab.
Once placed in a level, you can assign a model, and then enter the string of the in game animation name, as seen in the following screenshot:
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.218.196.182