I have set the coefficients of a Cloth object in Unity 2017.1.1f1. I update them 5 seconds in and they do not get appear to be updated in the Scene view. If I set a breakpoint, the coefficients have indeed changed, but the Cloth object still maintains the old values and behavior. I am attempting to clear out all the values for maxDistance to be the Maximum value. it seems to work, but the Cloth does not change its behavior. Any ideas? Thanks!
Cloth[] clothObjects = FindObjectsOfType(typeof(Cloth)) as Cloth[];
foreach (Cloth cloth in clothObjects)
{
ClothSkinningCoefficient[] newCoefficients = cloth.coefficients.Clone() as ClothSkinningCoefficient[];
for (int count = 0; count < newCoefficients.Length; count++)
{
newCoefficients[count].maxDistance = float.MaxValue;
newCoefficients[count].collisionSphereDistance = float.MaxValue;
}
cloth.coefficients = newCoefficients;
}
I tried. It did not work. You are correct that it a temp variable created for the loop, but it is a reference to object. So changing the temp variable should change the referenced object. Also, the values are changing. It is working. It is just not rendering the new values visually. I appreciate your ideas!