Is there a way to set the source object target via script for Two Bone IK constraint ?

I am using two bone IK constraint for my character to hold on to his weapons by constraining the hands to transform that correspond to the weapon handle ( lets call these handle transforms). Naturally, each weapon will come with its own handle transforms. I was thinking I could change the source object target dynamically during run-time to the equipped weapon’s handle transforms, is this supported by unity ?


you have to rebuild your rig builder to apply your new settings.
Example :

public TwoBoneIKConstraint leftHandIk;
public TwoBoneIKConstraint rightHandIK;
public RigBuilder rigBuilder;
public Transform rightHandTarget;
public Transform leftHandTarget;

void Start() 
{ = rightHandTarget; = leftHandTarget;
1 Like

I had the same problem but I managed to solve it!!
It’s the “data” variable!

TwoBoneIKConstraint ik;
void Start()
{ =;