- Home /
Inverse Kinematics - Turn off smoothly
I'm working on the Animations of a project and I'm using Unity's inbuilt inverse kinematics.
I have a NPC which has certain animations like "walk", "grab", "insert". Now once the NPC is in the grab or insert animation it should grab towards the current object. For this, I'm using inverse kinematics.
I have a parameter in my Animator called "IKWeight". To make the NPC's hand smoothly move towards the object and back to the original animation position, I use this code:
I turn the bool ikActive on or off, so i.e. it's on as the NPC is ready to grab, and off after the grab is done and the object is attached to the hand.
My NPC goes into the grabbing animation and without IK it just reaches in front of it. But with IK it should reach towards the object and then, after grabbing the object, return to where the animation was if IK was never used. After that it transitions into the walk animation which is why it should have been set back to the original position before then.
However, what happens is, that when grabbing the object (ikActive == true), the hand smoothly moves towards the object (which is what I want). However, once the object is attached and ikActive is set to false, it does not return to the original position smoothly. Instead, it just snaps/jumps to the original position. There is no smooth transition from the IK Position to the original animation position.
Here's a video showing the problem.
Now, my question is: Why does it not return to the original position smoothly? Does anyone see anything wrong with the code?
Thanks in advance!,I'm working on the Animations of a project and I'm using Unity's inbuilt inverse kinematics.
I have a NPC which has certain animations like "walk", "grab", "insert". Now once the NPC is in the grab or insert animation it should grab towards the current object. For this, I'm using inverse kinematics.
I have a parameter in my Animator called "IKWeight". To make the NPC's hand smoothly move towards the object and back to the original animation position, I use this code:
I turn the bool ikActive on or off, so i.e. it's on as the NPC is ready to grab, and off after the grab is done and the object is attached to the hand.
My NPC goes into the grabbing animation and without IK it just reaches straight in front of it. But with IK it should reach towards the object and then, after grabbing the object, return to where the animation was if IK was never used. After that it transitions into the walk animation which is why it should have been set back to the original position before then.
However, what happens is, that when grabbing the object (ikActive == true), the hand smoothly moves towards the object (which is what I want). However, once the object is attched and ikActive is set to false, it does not return to the original position smoothly. Instead, it just snaps/jumps to the original position. There is not smooth transition from the IK Position to the original animation position
Here is a video showing the problem.
Now, my question is: Why does it not return to the original position smoothly? Does anyone see anything wrong with the code?
Thanks in advance!