View Full Version : Loop attribute with MEL...?
04-21-2006, 08:54 PM
For a hulking robot character I'm trying to build something like an internal combustion engine in his torso, with the pistons pushing up and down in the engine block. I built the block and the pistons, and parented those to the block. I then made a 12-frame-long PistonMove attribute on the engine and set a driven key to make the pistons move up and down. So far so good; with the power of MEL it can be set to loop indefinitely. ...That's the theory anyway.
--That's what I wrote. The problem is, when the PistonMove attribute is reset to 0 (or whatever other number I entered) it stays there; it stops moving according to the passage of frames. Where have I gone wrong here?
04-22-2006, 02:09 AM
Do you want the pistons to be moving for ever when you hit play? If this is what you want, you have to set your attribute equals time, like:
MotorHousing1.PistonMove = time;
and if you want it to be faster just multiply time by a value, like:
I think this is what you want...
04-22-2006, 02:15 AM
I think I understood it wrong dude. Sorry for that. You sure want it to repeat for ever. But you want that everytime that MotorHousing1.PistonMove=12, then it starts back from 0 am I right? this can't be done with the expression I gave in my last post..
04-22-2006, 02:44 AM
Try a remainder operation.
MotorHousing1.PistonMove = (frame % 4) / 4 ;
04-22-2006, 05:25 AM
Sorry guys; neither of those worked :\
I'm looking over my scripts, and I guess I can see the problem..
I first tell Maya that the piston movements are directly related to the frame numbers, divided by 4. Then I tell it that if the attribute goes higher than 12 then it should go back to 0.... The problem is that the frames -- and by association the piston attribute-- just keep going, and at no point after frame 48 will the math equate to less than 12. So I know what's wrong, but since I don't know much about MEL I haven't got a clue what I can do about it...
04-22-2006, 07:05 AM
MotorHousing1.PistonMove = ((frame /4) % 12);
04-22-2006, 07:28 AM
Holy cow, that worked! Thanks, isoparm! I'm still kinda curious how it works, but I'll just look up Remainder functions and figure it out on my own...
You've save my butt for another day, man!
04-22-2006, 11:09 AM
04-22-2006, 02:51 PM
yhea Chris...thats it...
04-22-2006, 02:51 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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.