Rig & Procedural Animation

-C# script | Inverse Kinematics | Blender | Unity Engine

  • Procedrual Animation made with Unity Animation Rigging package.
  • Character rigged in Blender.
  • The script includes adjustable parameters for different movement styles.
  • Raycast and Gizmos are displayed in the Unity Editor for visualizing targets and ranges.

       This is a character rigged in Blender with a C# script for Procedural Animation in the Unity Engine. It offers procedural animation functionality for character models and utilizes the Unity Animation Rigging package and a combination of adjustable parameters to control leg movements.

-Rigging Process

      Setting out to create a procedural animation, my primary focus is in replicating fluid, organic motion. The rigging process forms the basis of the project, involving the creation of a skeleton that accurately mirrors a spider's articulation, utilizing Inverse Kinematics (IK) to ensure fluid limb movement.

      To further optimize the rig, custom curves or control handles are assigned to each joint, easing the manipulation of joint positions. Weight painting is employed, dictating the vertices' movements under each bone's influence, ensuring the robot's deformation during movement remains realistic.

Spider Robot Rig GIF

Procedural Animation Script

The Procedural Animation Script, developed using C# with Unity's Animation Rigging Package, enables the creation of realistic and responsive movement for multi-legged characters like spiders or robots. It leverages procedural animation techniques to achieve lifelike locomotion and interaction with the environment.

Setting Up Leg Movement Parameters

Customization options in the Unity editor allow adjustment of key parameters. These include stepDistance, stepHeight, and stepSpeed, determining the stride length, elevation, and speed of each leg movement. Additional parameters like velocityMultiplier and cycleSpeed adjust the character's pace based on its velocity.

Timings and Leg Movements

The script provides flexibility in managing leg movements. Leg movement timings can be set manually using manualTimings or calculated automatically based on timingsOffset. The script employs raycasts and a layer mask (layerMask) to detect and adapt to the terrain beneath each leg, ensuring a realistic interaction with the environment.

Advanced Timing and Refresh Rates

To maintain smooth movement, the script updates leg timings at regular intervals. The refreshTimingRate parameter determines the timing refresh rate and triggers the UpdateTimings method, ensuring synchronized and fluid leg motion.

Implementing Steps and Movement

The core of the procedural animation is executed within the Update method. It checks leg timings and initiates leg movement using the SetUp method when necessary. The MakeStep coroutine animates leg movements towards the target positions, taking into account the ground topology and other factors.

Visual Feedback with Gizmos

To facilitate visual debugging and provide insights into the movement logic, the script includes the OnDrawGizmosSelected method. This feature draws debug information in the Unity scene view, allowing visualization of target points, default leg positions, and the ground check range when the game object associated with the script is selected.