Ground Alignment Examples
The Beast demo scenes contain working CharacterController integrations. DemoAnimationSimple is the clearest starting point because it contains one directly controlled Beast and a compact movement loop.
DemoAnimationSimple
Open Assets/CreatureKit/Beasts/Demos/DemoAnimationSimple.unity.
The controlled Beast has:
- a generated
BeastStructure; - a
CharacterController; BeastCharacterGroundAlignment;DemoAnimationSimple, which owns input, gravity, movement, facing, and animation selection.
The movement script demonstrates the complete ground-alignment sequence:
Vector3 groundUp = groundAlignedController.GetDesiredGroundUp(Time.deltaTime);
Vector3 groundVelocity = controller.isGrounded
? groundAlignedController.ProjectVelocityOnGround(horizontalVelocity, groundUp)
: horizontalVelocity;
controller.Move(motion);
groundAlignedController.RotateControllerTowards(facingVelocity, rotationSpeed, Time.deltaTime);
groundAlignedController.AlignVisualToGround(facingVelocity, groundUp, rotationSpeed, Time.deltaTime);
groundAlignedController.DrawGroundProbeDebugLines();
Use this scene to tune one Beast before applying the same integration to AI-controlled groups.
Suggested Test Sequence
- Start on flat ground and enable
Draw Body + Legs Center. - Enable
Draw External Foot Raycastsand verify every active ray starts at the expected foot contact and reaches the intended terrain layer. - Enable
Draw Ground Normalsand compare yellow, magenta, and green lines. - Move uphill and downhill on the same slope.
- Repeat with Walk and Rush to observe temporary contact loss as feet lift.
- Repeat on a steeper slope, with ShyMoon's two probes, and with a Beast that has unusual proportions.
- Disable all debug views after validation.
Cowraffe Proportion Test
Cowraffe is a useful regression case because its long neck makes a whole-creature bounds center unsuitable for locomotion.
The orange support center must remain based on Body and Legs. Enabling or disabling the Cowraffe neck must not move that center. When uphill and downhill behavior differs, inspect the external foot contacts and rotation reference before compensating with a constant vertical offset.
This example illustrates why decorative appendages are excluded from controller fitting and ground-alignment support calculations for every Beast, not only Cowraffe.
DemoWildBeasts
Assets/CreatureKit/Beasts/Demos/DemoWildBeasts.unity applies the same API to multiple autonomous Beasts. Use it after the single-creature test to observe:
- many different body proportions;
- roaming direction changes;
- uphill and downhill movement;
- the cost of enabling debug output on many creatures.
The demo controller is application-side sample code. It is not required by Creature Kit runtime components and can be replaced by a game controller, AI, or navigation system.
API
See BeastCharacterGroundAlignment for the public component members used by these examples.