View Full Version : advanced expressions in Maya
02-19-2002, 10:41 PM
Hello. I am working on a set of expressions to controll an attribute on one object , when the min is 0 and the max is 1. I want it to be controlled the movement of another object translating on the Z. I was wondering if anyone knew how to make the attribute return to 0 after it reaches 1. At the same time, I would like it to continue increases after it goes back to 0 it the other object continues to translate on the Z axis. What I am basically wondering if anyone knows how I can get the attribute to "loop" after it hits one I tried an expression with a clamp, but it only stoped after it reached the value of 1. If anyone could help lead me into any kind of dirrection to solve this problem, I would appreciate it.
Also, does anyone know how to make an object controlled by the translation of another object, not necessarly by not using its coordinates (x,y,z), but the difference betweens its curent position and its last position. Thank you for your time,
02-20-2002, 11:26 AM
For your first question, I think you mean this.
Put a sphere at 0 0 1.
Put a cone at -5 -5 0
nurbsSphere1.translateZ = (frame/10)+1;
(or something like this - it could be keyframed)
to the sphere and:
$offset = (nurbsSphere1.translateZ);
nurbsCone1.translateY = $offset-trunc($offset);
to the cone.
02-20-2002, 05:26 PM
Thanks alot I will try it tonight.
02-20-2002, 05:27 PM
Sorry, I am trying to learn this as I go, what does the trunc function mean? Thanks,
02-21-2002, 04:33 AM
I tried a modified version of the expression that you wrote, and it fixed both questions. I was also wondering how you add to an expression, so that if I were to rotate the sphere, it would make the cone go the other way, I would still like to keep the same speed and stuff. I can't seem to get two different attributes to change a single attribute on the other. Thank you for your time,
02-21-2002, 06:14 AM
If anyone out there understands expressions well, Do you know how I can fix this?
$tred = (tank.translateZ/25.5);
$tred2 = (tank.rotateY/51);
$tred3 = (tank.translateX/25.5);
ikHandle1.offset = $tred2-trunc($tred2);
else if (tank.translateZ)
ikHandle1.offset = $tred-trunc($tred);
ikHandle1.offset = $tred3-trunc($tred3);
As of right now, it pretty much works as long as I stay in the positive (no neg.) and as long as I only move in the x or z plane dirrectly. if i rotate the tank any other angle beside 90, 180, 360 ect... and move it, it moves on both x and z planes at the same time so the expression does not work, this is a big problem, i was wondering if anyone had any sugestions on how i could fix it. thank you for your time,
P.s. Actually the translateZ works and the rotate y works, but the translateX does not work.
01-13-2006, 01:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.