Defining Root Motion Policies for a Walking Character
In this task, let’s take an example of root motion policies for a biped character walking on a ground:
For
RED::RMC_ROTATION:
the rotation is handled by the animation and stays absolute. We setRED::RMP_DEFAULT
with no extraction.For
RED::RMC_POSITION_X
andRED::RMC_POSITION_Y:
the translations on the X and Y axes are handled by the animation but we want a relative motion. We setRED::RMP_DELTA
with extraction and apply the delta transform ourselves on the parent shape.For
RED::RMC_POSITION_Z:
the character should follow the ground level, the translation on the Z axis is handled externally. We setRED::RMP_ZERO
.
// RED::Object* animController is a skeletal animation clip controller.
RED::ISkeletalAnimationController* iskeletalController = animController->As< RED::ISkeletalAnimationController >();
// Rotation is handled by the animation.
RC_TEST( iskeletalController->SetRootMotionPolicy( RED::RMC_ROTATION, RED::RMP_DEFAULT, false ) );
// Translations on X and Y axes are handled by the animation by applied on an external shape.
RC_TEST( iskeletalController->SetRootMotionPolicy( RED::RMC_POSITION_X, RED::RMP_DELTA, true ) );
RC_TEST( iskeletalController->SetRootMotionPolicy( RED::RMC_POSITION_Y, RED::RMP_DELTA, true ) );
// Translation on Z axis is handled externally.
RC_TEST( iskeletalController->SetRootMotionPolicy( RED::RMC_POSITION_Z, RED::RMP_ZERO, false ) );