Yes, this is the intended way to set sourceObjects in Multi constraints. sourceObjects is of type WeightedTransformArray which is a struct, so calling SetWeight on it directly just modifies a copy of the data.
You could also simplify your working code with the following:
var a = aimConstraint.data.sourceObjects;
a.SetWeight(0, x);
a.SetWeight(1, y);
aimConstraint.data.sourceObjects = a;
I don’t quite understand why you would want to copy the whole struct everytime just to change a value and then copy it back… why can’t you just edit it in place? That’s what SetWeight() should be for.
WeightedTransformArray is defined as a struct which is a value type. Therefore, directly calling SetWeight on sourceObjects would only modify a copy of it.
By making WeightedTransformArray a struct, we also allow for the weight values to be animated. This wouldn’t have been possible with a class.