This recipe works for Humanoid characters only. It uses the Unity's built-in inverse kinematics solver. The key elements of this recipe are as follows:
- Animation Curve: We use an Animation Curve to smoothly set the weight for the IK solver during the Pickup animation playback.
- SetIKPosition(): This function sets the target position for a given body part. We are using a public Transform ikTarget variable in the script and pass it to the function. You can get the target in runtime.
- SetIKPositionWeight(): This function sets the weight of the IK solver. A weight value of 1 means that IK is in full control of a given body part and a value of 0 means that the animation is in full control.
- IK Pass: To be able to use inverse kinematics for Humanoid characters, we need to enable the IK Pass option in the controller's layer properties.