Setup:

Code in a function
WeightedTransformArray a = TertiaryWeaponRig.data.sourceObjects;
a.SetWeight(0, 1f);
a.SetWeight(1, 1f);
TertiaryWeaponRig.data.sourceObjects = a;
I have tested to insure the sourceobjects (weaponPivot/WeaponSlot) are in the sourceobjects object when running. When the script runs the weight is not set. I have tried everything i have found online and i have not been able to get multi-parent constraints source objects weight to change at run time.
Is this a bug or am i doing something incorrectly?
I found that the problem is when you set the weight in a function or a coroutine. This function above only works if you run it in a update function. This seems really silly to me.
Coroutines run after update therefor i dont know if it is possible to set the weight outside of a update that runs every single frame.
Does anybody have any ideas?
This is still the case, updating the Multi-Parent Constraint source doesnt work in a non Update() function.
What does work, maybe there is a better way?
You can change the WeightedTransformArray weights in a function.
public void ChangeWeights()
{
refWeightedTransforms.SetWeight(0, 0f);
refWeightedTransforms.SetWeight(1, 1f);
isDirty = true;
}
Then you have to set the Multi-Parent Constraint source object in Update.
public void Update() {
if(isDirty){
isDirty = false;
refMultiParentConstraint.data.sourceObjects = refWeightedTransforms;
}
}
Thanks for posting this way back in 2021!