How do I access this weight value?

Hey y'all,

I'm trying to access this value from the TwoBoneIKConstraint script:

And I'm getting the component like this:


That's not working because it says that the type doesn't exist and I'm probably doing it the wrong way -- so how do I go about accessing this component?

Also I wonder if I can change it at runtime? I don't want to animate the value with the animator or do it via the Inspector.


Yes its definitely possible to change the weight at runtime.

TwoBoneIKConstraint constraint = gameobject.GetComponent<TwoBoneIKConstraint>(); = 0.7

You can control other parameters too but you can't change the sources or targets at runtime for example since they are part of the animation graph built once when you start the game.

For some reason the TwoBoneIKConstraint type just doesn't exist for me to be able to reference it like that (see original post).
Am I missing something here?

1 Like

Hi, it should work, maybe you forgot a using directive ?

Which directive should I include in my script?
I tried adding UnityEngine.Animations.Rigging or something like that and also the UnityEngine.Experimental.Animations but neither of them have that class defined.

UnityEngine.Animations.Rigging should be the right one, so it doesn't seem to be the problem here.

What do I do?

You need to be using the namespace "UnityEngine.Animations.Rigging".
Just put this line at the top of your file:

using UnityEngine.Animations.Rigging
If this doesn't work, let me know. It might be because you are on a different version of Unity. Also, make sure that you are updated to the latest version of the Animation Rigging package, you can update through the Package Manager.

As I've mentioned before, I did use that namespace and the other from Experimental, but neither didn't have the class defined.
I was using Unity 2019.3 and the Animation Rigging package was up to date (when I first posted this)

I decided to go for a different approach since this doesn't work, so thanks anyway...

Nice same problem - using UnityEngine.Animations.Rigging, and get "UnityEngine.Animations.Rigging" not exists ! Great !)

Im find a way - this is a reference bug. need refresh a reference library in project

1 Like