PDA

View Full Version : Execute Expression on every frame??


knoxie
11-24-2006, 03:12 AM
Is it possible to get maya to add constant a value to a float on every frame? Ultimately I want to control the translateX of a vehicule based on a custom speed control.

eg:

//Adds 1 to itself on every frame
$addOne = ????;

//vehicule.speed is a custom attribute to control translateX speed
$speed = vehicule.speed;

//vehicule starts at 0 in translateX and increases based on vehicule.Speed
vehicule.translateX = 0 + ($addOne * $Speed);


It sounds simple... but for the love of god i can't get my head around the $addOne bit.

Cheers.
Carl

ashishdantu
11-24-2006, 03:34 AM
hi,

ur expression is by default evaluated when ever time change is triggered.

u can try this :


$addOne = vehicule.amount; // add an attribute on ur vehicule
// or
$addOne = 1;
vehicule.translateX += ($addOne * $Speed);

is this what u r looking for ? vehicule.tx += (something)...here the += means >
vehicule.tx=vehicule.tx+(something);

hope this helps...

knoxie
11-24-2006, 04:04 AM
Thanks for clearing that up for me so quickly man.

Now all i need to do is figure out how to reset back to zero at frame 0.

Thanks again.
Carl.

ashishdantu
11-24-2006, 05:13 AM
hi,

edit ur expression to..

if (`currentTime -q`!=0)
{
$speed=vehicule.speed;
$addOne = vehicule.amount; // add an attribute on ur vehicule

vehicule.translateX += ($addOne * $Speed);
}
else
{
vehicule.translateX = 0;
}

-rgds,

knoxie
11-26-2006, 08:53 PM
hey ashishdantu,

Man i've got to school myself in MEL...

Thanks again Mate.
Carl.

CGTalk Moderation
11-26-2006, 08:53 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.