Cloth Constraint


Hello All.

I’ve got a 13" x 1" NURBS square. Converted it to cloth. At one end I’ve attached a locator and transfrom constrained it to the verticies of the cloth. When I animate it one end of the cloth falls do to gravity the other end is locked to the locator and stays stationary. What I want to do is attach some spheres on the cloth that will follow the cloth as it falls. I’ve been trying to figure this out and am having no success. The closest I came was attaching the spheres to the cloth with a geometry constraint. I delete my cache and play the animation. One end of the cloth falls do to gravity spheres follow it but slide down the cloth to the end of the cloth geometry. PLUS, when the animation starts over the spheres are not located in their correct position, Maya moves them all to the same spot. Any help is good help.



I believe what you want is a cloth “Button” Constraint.

From the maya 6 help file:

“…button constraint. When it is created a transform is created and updated every frame, which tracks the position and orientation of the cloth. You can parent an object to the transform and it will follow cloth like a button does”
Good luck.


Thanks for the reply. I tried using a button constraint and had all sorts of trouble with it. I read the Maya documentation many times and I can’t figure out what is wrong. It seems so simple. I’ve got a piece of cloth it animates properly. When I try to attach a sphere to the cloth using a button constraint the first thing that happens is Maya moves my sphere far away. When I play the scene the sphere moves similar to the cloth but it didn’t start where it should’ve and definitely didn’t end where is should’ve. If I move the sphere to where it needs to initially start, freeze the transformation and then apply a button constraint I can at least get the sphere to start in the correct spot. However upon playing the scene the sphere flys way off of the cloth? Cache was deleted. It’s really frustrating. Any help would be appreciated.



I have used cloth in maya quite a bit but have never had a real need to use the button constraint. But you are right, it doesn’t seem to work as advertised. I fact it works frustratingly bad and no where near how the help files describe it.

So I made my own sort of button constraint using an expression:

float $button[] = pointPosition clothShape1.vtx[180];
pSphere1.translateX = $button[0];
pSphere1.translateY = $button[1];
pSphere1.translateZ = $button[2];

This expression constrains an object (pSphere1) to a vertex (vtx[180]) on a piece of cloth.

[color=white]It seems to work but there are a few problems:

  1. the expression won’t evaluate during a local cloth simulation, however it works fine when the timeline is played.

  2. if the cloth resolution is changed the vertex array will change with it, causing the vertex of the given number (here [180]) to change position.

  3. the biggest problem…this only point constrains the object to the cloth. It doesn’t take into consideration the rotation on the cloth. In fact, at the moment I have no idea how to set that up…maybe someone else out there would.

Sorry for the small text… how do you format text on this thing?? Blah.

Good luck.




That script works really well. And the problems with it are easily controlled. I even added more than one sphere to the equation and it worked well for all of them. I appreciate your help. My understanding of mel is basic at best. I would’ve never tried to use it but would however, like to learn it. Do you have any suggestions?



Have you guys ever heard of the Rivet or Button Conistraint? Its a script that exists on Highend. It allows a locator the attached to 2 isoparms then you can parent or coinstrain your obj to the locator. I have never used it on cloth but I have use it for other things and its great. Do a search on highend for it if you can’t find it drop me a line and I can send it to you. :thumbsup:


Great tip notoshabi. It looks like the Rivet script should work fine for cloth because its supposed to work on polygons as well.

As for learning MEL dweinin, I highly recommend the “Complete Maya Programming” book and, though I don’t own it “MEL Scripting for Maya Animators” looked really good when I thumbed through it at the bookstore. Also, learning a highlevel laguage like C/C++ or Java will absolutly apply to MEL. Other than that, simply opening the script editor and watching Maya echo commands is very helpful.


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.