CRYENGINE can automatically adjust the character's legs and feet to match the surface of the terrain or ground he is standing on.
This includes the foot aligning to the direct of the slope in addition to the leg adjusting to different heights.
Animated Character must be used for ground alignment and foot / leg IK to function. This means that simple entities like the animobj entity and others will not use this function. The character must be a live animated character, which can be accomplished by using the default player class or default AI classes such as human.
The character's skeleton needs to have certain bones and names in order to make the groundAlignment work. This setup needs to be done in the character's .chrparams file. Setups for both legs must be added to the file:
<LimbIK_Definition>
<IK EndEffector="Bip01 R Foot" Handle="RgtLeg01" Root="Bip01 R Thigh" Solver="2BIK"/>
<IK EndEffector="Bip01 L Foot" Handle="LftLeg01" Root="Bip01 L Thigh" Solver="2BIK"/>
</LimbIK_Definition>
To find the surface beneath the character's feet, rays are cast from a place above his heel bone to find a collision with the surface. The foot is also aligned to the surface. The character's skeleton must provide the following bones:
As with previous versions of the engine, animated character classes must be used if you wish to have the adaption, using the animobj entity or something similar will not function.
Within 3.5 there are a few less specific naming conventions that must be followed, however, the setup is similar to 3.4
1. Setup the required naming conventions that are written in C++ within the InitializePoseAlignerBipedHuman function.
2. Define the joints that will be affected in the .chrparams file.
<LimbIK_Definition>
<IK EndEffector="Right_Foot" Handle="RgtLeg01" Root="Right_Thigh" Solver="2BIK"/>
<IK EndEffector="Left_Foot" Handle="LftLeg01" Root="Left_Thigh" Solver="2BIK"/>
</LimbIK_Definition>
3. Setting up the Bip01 PlaneTarget and PlaneWeight bones.
The plane target and plane weight bones are setup in the rig to give the system an absolute offset limit. The pose aligned drives the plane target node to align to the plane weight node and no further.
Plane Target Node in Center of Foot
Plane Weight Node Aligned to Pelvis on Z , Zero on Y and Over the foot on X.
Hierarchy setup display
4. Debugging
Here are some very useful console variables to see that the pose aligner is active:
Use ca_groundAlignment to turn on and off the automatic ground alignment on all characters globally. By default this value is set to 1, which means it is active.
The Flow Graph node Animations::GroundAlignment can be used to enable or disable this feature during the game.
This gives designers control over turning ground alignment on/off for individual characters at run-time.
Like the Flow Graph node described above, this feature can be disabled/enabled for individual characters at run-time via code as well.
The interface function is declared in ISkeletonPose:
SkeletonPose::
virtual void EnableFootGroundAlignment(bool enable);
To activate or deactivate the alignment from within the game dll actor or player implementation, use this code:
GetEntity()->GetCharacter(0)->GetISkeletonPose()->EnableFootGroundAlignment(true);