How to continuously query an attribute value?


#1

So as it will become apparent, I am very new to Mel and don’t know most of the syntax yet. I’ve created a code that will create an attribute for an object, assign the value from querying the attribute to a variable, and use that variable in a sine expression.

Also I don’t know how to share code most effectively on this site, bear with me

polyCube -w 1 -d 1 -h 1 -n "Boop";
circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1 -n "Control";
scale -r 2.740463 2.740463 2.740463 ;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
parent -r -s Boop Control;

addAttr -ln "Animate"  -at double  -min 0.1 -max 1 -dv 0.1 Control;
setAttr -e-keyable true Control.Animate;
addAttr -ln "Move"  -at double  -min 0.1 -max 90 -dv 0.1 Control;
setAttr -e-keyable true Control.Move;

float $speed = `getAttr -time n Control.Animate`;
float $move = `getAttr -time n Control.Move`;

string $anim2 = "Boop.rotateY = sin(frame * "+$speed+")*("+$move+");";
expression -s $anim2;

I know the problem is the code only queries the value of the attribute once, then never re-evaluates even if I change the attribute. How do I continuously query the value?