PDA

View Full Version : Moving obejects with mel?


nottoshabi
07-16-2007, 06:22 PM
I want to move 3 objects with one control. For example I have 4 spheres and sphere 1 is the control. Now when sphere one is in positive the other 3 spheres are also in positive. When the sphere goes in negative the other three spheres go in negative. How can I do that in mel and in expressions?

trancor
07-16-2007, 09:31 PM
Can't parent or use set driven keys?

Is the sphere moving with the other spheres or do you want it to be like, move the one sphere to another area and have the other spheres move to a different area more independantly than set driven keys?

nottoshabi
07-16-2007, 09:38 PM
It can not be set driven keys. It needs to be code cause this is an example of something else. For example: If Sphere 1 is at ty 10 then Sphere 2, 3 and 4 nedds to also be at ty 10. And if it goes to -10 the other 3 spheres need to do the same thing. I just need to see the code formation. Cause what I wrote is not working. I think I'm not declaring it right.

trancor
07-16-2007, 10:11 PM
Well, don't really know how you want it writen,


You can't do something like this?


vector $objController=`getAttr pSphere1.translate`;

setAttr pSphere2.translateY ($objController.y);
setAttr pSphere3.translateY ($objController.y);
setAttr pSphere4.translateY ($objController.y);



Or do you need something like this ?


float $switchMax=10;
float $switchMin=-10;

float $objMax=15;
float $objMin=-15;


float $switchY=`getAttr pSphere1.translateY`;

float $percentage=($switchY)/(abs($switchMax)+abs($switchMin));

$place=((abs($objMax)+abs($objMin))*$percentage);
setAttr pSphere2.translateY $place;


This finds the distance between the max and min distance the switch can move and gets the percentage between the two numbers and then places the other object between the objects set max and min movement values. The numbers are just a refrence, if you move the sphere switch further than the numbers, it just gets the larger percentage to place the controlled object at the same percentage of the set movement area.

If I missunderstood you, just say.

CGTalk Moderation
07-16-2007, 10:11 PM
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.