Technical Animation
Figure One: Demonstration of Inverse Kinematics being used by the playable mount.
Figure Two: Demonstration of Inverse Kinematics being used by Geb, one of the games bosses.
Technical Animation
Procedural Inverse Kinematics was implemented for one of the boss characters, Geb, and implemented for the player-controlled mount, which required implementing an Inverse Kinematic manager into two different existing models.
The IK management system was developed to be supported in usage by both AI characters, which move via NavMesh Agent, and by player input, via Character Controller, in turn via either Unity’s new or old Input System.
IK_ControlsAndValues – Processing Input and Modification of IK System
The IK_ControlsAndValues script handles inputs and provides many exposed properties that can be customised by a developer to fine tune how the Inverse Kinematic solution is implemented and the way the main body should move. Examples include the arcing height of legs when stepping, auto calculating foot movement speed based on body speed, body height offset from ground and even allowing either global values to affect leg movement or controlling each leg movement individually through the IK_RayCastPredictor script.
Figure Three: Extract of the Inspector for the IK_Controls And Values Script which controls the inputs and influences how the manager handles the movement of the IK Body and also influences how the feet move.
IK_Manager – Translating Input into Body Movement
The IK_Manager processes the inputs received from IK_ControlsAndValues and translates that into movement of the main body of the IK controller, via moving either the NavMesh Agent or the Character Controller.
Figure Four: Inspector of the IK_Manager along with the Character Controller used to move the IK character.
Figure Five: Inspector of the IK_Manager along with the NavMesh Agent used to move the IK character.
IK_RayCastPredictor – Controlling Leg Movement via RayCasts and Lerping
Figure Six: Display within the Unity Editor of the IK System.
The Yellow capusles send of a RayCast either downwards or in the direction of movement.
The Green flat sphereoids at the RayCast projected “predicated” location the foot could reach given sufficent movement of the body to exceed leg stride.
The Red spheres at the ends of the feet act as target points where the feet will always move too - these are the points lerped when feet move from one positon to the predicted location.
The Grey spheres are simply the angle at which the joints should curve from the centre.
The IK_RayCastPredictor script handles the specifics of how the leg finds a new location and when and how it moves to a that new point. The feet find locations on the floor to step-towards via RayCasts completed in the IK_RayCastPredictor script, and lerp the foot positions towards the predicated location when sufficient distance has been made during movement.
When unable to find a foot location, a SphereCast is completed closer to legs base to the main body to find another valid foot position. On failure again, a default in air position is used, to simulate the foot being held up.
Improvement to IK System
Improvements to the IK system developed also came from the feet always returning to a neutral position when no movement is happening to the main body. Giving a natural resting place for the legs when idle. Also, the feet move in two different gaits to provide natural and realistic movement – either walking each foot at a time at low speed, or at higher speeds, multiple feet are allowed to leave the ground at once.