Character Controller Pro (1.4.x)
  • Introduction
  • The package
    • Content
    • Versioning scheme
    • Importing the package
    • Using the package
    • Known issues
  • Fundamentals
    • Core
      • Character
      • Character body
      • Character actor
        • States
        • Stable movement features
        • Velocity
    • Implementation
      • Character state controller
      • Character state
      • Character brain
  • How to...
    • Core
      • Create a basic character
      • Add behavior logic to your character
      • Move the character
      • Rotate the character
      • Leave grounded state (e.g. jump)
      • Change the size of the character
      • Disable collisions (ghost)
      • Use the character information (with examples)
      • Use root motion
      • Detect a character using a "detector"
      • Add a static one way platform
      • Add a dynamic one way platform
    • Implementation
      • Organize the character hierarchy
      • States
        • Add and configure the state machine
        • Create a state
        • Transition from one state to another
        • Handle animation
        • Modify an IK (inverse kinematics) element
      • Actions
        • Define your own actions
        • Use the character actions
        • Use a custom Input Handler
        • Use the new input system
        • Create your own AI movement logic
Powered by GitBook
On this page
  1. How to...
  2. Implementation
  3. States

Modify an IK (inverse kinematics) element

The process of modifying an IK element (left foot, right foot, left hand or rght hand) is exactly the same as always was. Basically changing the Animator component directly.

Since the Animator could be anywhere (within the hierarchy), you cannot just use the message Unity provides for this (OnAnimatorIK), because the state script needs to be in the same object. In order to use this message you need to override a special virtual method (from the CharacterState) called UpdateIK.

For example:

public override void UpdateIK(int layerIndex)
{
    // Set the weight
    CharacterActor.Animator.SetIKPositionWeight(avatarIKGoal, positionWeight);
    
    // Set the position
    CharacterActor.Animator.SetIKPosition(avatarIKGoal, position);    

}

PreviousHandle animationNextActions

Last updated 2 years ago