My code starts with one constraint on the cloth, defined in the editor. My goal is to remove that constraint and add another constraint at a different point, both in code.
ClothSkinningCoefficient[] coefficientsCopy = cloth.coefficients;
coefficientsCopy[vertexToConstrain].maxDistance = 0;
// An unconstrained vertex seems to be listed as float.MaxValue in code
coefficientsCopy[vertexToUnconstrain].maxDistance = float.MaxValue;
cloth.coefficients = coefficientsCopy;
When I check cloth.coefficients[vertexToUnconstrain] after this code is executed, it’s set to float.MaxValue, and if I pause the editor and check the constraints under “Edit Constraints”, the vertex at vertexToConstrain is marked as constrained and vertexToUnconstrain is marked as unconstrained, but vertexToUnconstrain still behaves as though it is constrained in-editor.
To illustrate:
Here is the cloth before I run the simulation. The only constrained vertex is in the upper center (which will be VertexToUnconstrain when I run the simulation).
Here is the cloth after I run the simulation. I’ve selected the vertex in the upper left corner as vertexToConstrain, and vertexToUnconstrain (upper right corner) is no longer marked as constrained. However, it still behaves as though it were constrained.
Thanks for your help!