- Home /
Transform all interactivecloth vertices manually
My question is: How to transform all interactive cloth vertices manually?
The Interactive Cloth Docs(Bottom) says it should be possible, but not HOW to do it.
Test 1 - change the vertices directly
InteractiveCloth cloth = GetComponent(typeof(InteractiveCloth)) as InteractiveCloth;
for (var i = 0; i < cloth.vertices.Length; i++)
cloth.vertices[i] += Vector3.up;
Nothing seems to happen...
Test 2 - Set the vertices
InteractiveCloth cloth = GetComponent(typeof(InteractiveCloth)) as InteractiveCloth;
Vector3[] newVertices = cloth.vertices;
for (var i = 0; i < newVertices.Length; i++)
newVertices[i] += Vector3.up;
cloth.vertices = newVertices; // <--- Error: Property or indexer 'UnityEngine.Cloth.vertices' cannot be assigned to -- it is read only
It seems I cannot do it because Cloth.vertices is read only.
Help.
Edit:
To clarify my question a bit more: The docs for interactive cloth says: "Cloth is being simulated in world space and does not get any changes you make in transform. In case you really want to move the cloth directly without applying any forces you are free to transform all cloth vertices manually."
But it doesn't explain how to "transform all cloth vertices manually".
any luck with this? I cannot figure it out either. since you can also get the cloth.mesh I was fiddling with that for a bit BUT that is only the start mesh and by changing that the cloth obviosly resets and looses any velocity it had....
cloth.mesh seems to be the a shared mesh. So if i change the mesh all the other instances of that mesh in the screen will be changed too... kind of a unwanted side effect ;)
it's pretty limiting. I'm using it to force a softbody ball stay in it's z space. I've moved away from that now and nor im using two invisible colliders to "trap" the ball. $$anonymous$$inda a shitty way of doing it BUT it actually looks pretty good with 0 friction. I just also realised that intercloth collisions are NOT supported so now I have to figure out a workaround for that too. :) thinking outside the box or whatever......
Arvid_2, but that isn't changing the vertices manually? That is trying to get the physics engine to not move the cloth outside of a specefic space?
But thanks for the idea, sadly it doesn't solve my problem.
Your answer