How to change LimbSolver2D property Effector in script

In an animation created using LimbSolver2D, when a character with the same character is replaced during runtime, I want to use a script to change the associated effector to the bone of the new character. But I can’t find the effector anywhere in the script.
Is there a way?

Thanks.

Hello!
Have you consulted our documentation on LimbSolver2D, which may contain what you need?

https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/api/UnityEngine.U2D.IK.LimbSolver2D.html

I also noticed there is no way to set the effector transform programaticlly, without using the editor. If im missing this functionality let me know, but it would be nice if or something like it was added to LimbSolver2D.

 public virtual void setEffector(Transform effectorTarget)
        {
            if (m_Chain != null)
            {
                m_Chain.effector = effectorTarget;
            }
        }

        public virtual void createTarget()
        {
            IKChain2D chain = GetChain(GetChainCount());
            if (chain != null && chain.target == null && chain.effector != null)
            {
                chain.target = new GameObject(name + "_Target").transform;
                chain.target.SetParent(transform);
                chain.target.position = chain.effector.position;
                chain.target.rotation = chain.effector.rotation;

            }
        }
1 Like

bump

Try to get the chainIK and assign affector there.

IKChain2D ikChain = handGrabLimpSolver2D.GetChain(0);
ikChain.effector = transform;

Not tested on device build. Working fine in editor