SetIK on childobject's animator component?

Hello guys, bit new to this so probably just overlooking something simple!

I’m trying to set ik positions/rotations from a script that’s on parent object and I’m not having much success.

Getting the animator component like so: (and ofc attaching it in the inspector)

public Animator anim;

anim = GetComponentInChildren<Animator>();

or simply GetComponent();

Everything works if the script is on the same object as the Animator component(the child object)…so guessing I need to get the component in some other way?

I’m able to play animations / get/set properties etc… and other stuff that is related to the animator component just fine from the parent/script which mostly confuses me since that means it does find the component, and it allows me to set properties for it, just not for the IK?. Setting things for the IK is the only thing that doesn’t seem to work for now… Any ideas what I’m missing? :slight_smile:

Thanks in advance!

Inverse your pattern. Instead of controlling child, let child ask parent for values:

SomeBehaviourClass myParentObject;

private void OnEnable() {
  myParentObject = GetComponentInParent<SomeBehaviourClass>();
}

private void OnAnimatorIK()
{
   var someBodyPartGoal = parent.GetSomeBodyPartGoalFor(this);
}
1 Like