PDA

View Full Version : Writing Expressions


DigivisonStudios
04-23-2009, 06:46 PM
Hello,

My question i have should be somewhat simple considering the circumstances. I am developing a project for work and i am having trouble with multiply objects on a motion paths. i will write out how much Ive achieved so far and hopefully someone will answer my problem.

1. First i made a curve
2. Second i modeled a small 3d arrow that would flow on the curve in a motion path.
3. Selected object then curve and set to motion path with the timescale 1-1000
4. Once i lined up object on path i selected the arrow and created a animation snapshot every 25 frames. duplicateding them on the path
5. i then selected one of the snapshots and added a expression to the start frame that looked like this:

snapshot3.startTime = frame -20;

Now all the arrows flow together along the line however, stack up on the end frame 1000 when i want them to start at frame 1 on the motion path.
this is where i am stumped. i have been researching expressions and other options like post-infinity cycle in the graph editor no luck.

if there is a expression anyone know that would work such as

frame 1000=1

or anything that will allow the continuous flow of the arrows after they reach 1000. any help is greatly apprieciated. thanks

nate

mef
05-04-2009, 05:52 PM
I'm no scripting expert, but it sounds to me that you would need to have the expression check for the position along the path and once it got to that position then you would equate the position to the start of the path. It would not check frame count at all.

Marc

Karnageddon
05-05-2009, 04:21 AM
are you using something like a path constraint controlled by the percentage?? If so it would go something like this (it worked for me at least)


pathloop=percent*3
if percent>.99 then percent=0 else pathloop

Line 1:this will cause it to loop thrice; in my example it is controlled by a slider, so at every 33% it will start the next loop.
Line 2: pretty straight forward, if the percentage along path is higher than 99% then reset percentage along path to 0, (else) if the percentage along path is no longer 0, then pathloop will take over.

There's better ways of doing it but this was the only way i could figure out for you. Not very knowledgeable here either.

MolemanSD7
05-05-2009, 02:08 PM
That above code would fall a bit short. It would, in essence work up to .99, then go to 0 and sit there. You'd have to set it up to work if the value of a controller is >1, then the value is the control value -1. Then, if the value is >2, do Control value -2. In this way it would continue to loop. You can set up an expression to do all this...so you don't have a ton of if statements.

Karnageddon
05-05-2009, 04:14 PM
That above code would fall a bit short. It would, in essence work up to .99, then go to 0 and sit there. You'd have to set it up to work if the value of a controller is >1, then the value is the control value -1. Then, if the value is >2, do Control value -2. In this way it would continue to loop. You can set up an expression to do all this...so you don't have a ton of if statements.

Hm, makes sense except how would the controller go beyond 1 if 1=100%? I know if i try anything above .99 in max, it refuses to accept the expression.
Also, it doesn't sit there at 0, the loop expression on line 1 causes it to continue moving along the path, i was trying it out b4 i replied and it was working perfectly.

MolemanSD7
05-07-2009, 02:32 PM
I meant that if you have an attribute on a controller that is affecting the u-value of the object... the controller value could go beyond 1, but the actual u position would still be a fraction of the overall curve.

Ex: Say the value is set to 4.5, the expression would say okay... its above four, so the uvalue should be 4.5-4 = 0.5; Then it would keep looping.

Then again, I'm using Maya, so it may be a little different. He never specified his application. So, there may be some variation between max and maya, but the logic would still remain. Only the values would change.

CGTalk Moderation
05-07-2009, 02:32 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.