Noob Problem with "Move" Effect

Moderators: Disciple, zlovatt

Post Reply
Mark Antonio
Posts: 4
Joined: August 4th, 2009, 10:51 am

Hello guys,

i am new to this forum and new to ae expressions. i have a little animation where i use an expression to animate few masks on a white line to simulate a drive on a road by moving the middle of the road stripes. (hope you get what i mean as i am german and my english not so good) To reach my goal i use an expression on the move effects combined with a keyframed slider to raise the speed the masks move dynamically to simulate a speed raisement. below you see two screenshots of my animation and here is the expression on the "Move" effect's "move center point to" property:

Code: Select all

rate = effect("Slider Control")("Slider");  // Animation in pixels per frame
x = 0; 
y = rate * timeToFrames(time); 
value + [x,y]
( This code is no fruit of my own spiritual precious but the help of a friendly user in creative cow forum )

The slider has 3 keyframes (0, 5, 30). Now, there appear to be 2 major problems:

1) after the 3rd keyframe passed the speed slows down. i could absolutely not figure out why. i solved it (so i thought) by adding a 4th keyframe right 1 frame behind the 3rd and setting it to 75. Thus when the 3rd keyframe passed the speed stays optically continual. BUT...

2) ... now, after a while the whole animation stops. my guess is the problem described in this thread here in forum as the second value of the "move centerpoint to" property is 170750 at this time.

so my questions are:

a) why does the speed slow down as described under 1 ? why isn't it continued till the end of the comp?

b) how would i need to implement the "reset" part of the expression in the linked thread to my code?

i would really find it out myself but i dont understand the whole thing as i am a greenhorn with no experience on expressions. could you please send me the light and help me fix my problem?

regards from germany,

mark
Hauptkomposition.png
Hauptkomposition.png (14.84 KiB) Viewed 32830 times
street.jpg
street.jpg (37.9 KiB) Viewed 32830 times
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

It's hard to explain, but I'll give it a go. Expressions aren't well suited to variable "rates". A constant rate works fine, but as soon as you start animating it (as with your slider) things don't work as you might expect. The problem is that expressions don't know anything about what's happened in the past. So at a particular frame, the result your expression calculates is the same as it would be if the slider had always been at its current value. So, to accurately do what you're trying to do, you need a more complex expression that either:

a) Loops throught the timeline, frame-by-frame, calculating the contribution of each frame (with the value of the rate slider at that time) to the overall movement. This would be a kind of integration or accumulation loop.

b) If your keyframes are linear, you could do some triangle math that looks at all the previous keyframe values and calculates the effect of each previous keyframe (plus the next one in the future).

As an alternative, you might consider running your animation at a constant rate, then precomping and time remapping.

Dan
Mark Antonio
Posts: 4
Joined: August 4th, 2009, 10:51 am

thanks dan for your answer and your suggestions. i tried to get a workaround with the 2nd option. so i created a new comp with 2 versions of my current street animation.

version 1: 3 keyframes (as already described)
version 2: 1 keyframe for a constant rate of 70 (to continue at the same visual speed)

i arranged these 2 buddies so that comp 1 gets cut right after the last keyframe and comp 2 starts immediately there. with a continual value of 30 for the 1 keyframe in version 2 (as is the value of the 3rd keyframe in version 1) the speed immediately slows down right after the "switch". this is the same behaviour as i had in my first comp where all 4 keyframes are in place. with a value of 70 i get the same result as already described in my opening post. animation breaks at around 00:01:15:00. i suppose the "reset" part described in the thread linked to be a solution. could this be possible? mabe it is indeed the case that ae is not possible to handle this high value (170750) i get after that time point. but a lower speed would make the whole animation boring. and i am not able to create a that complicated expression as described by you, dan, at this time since i am a beginner and don't have much time left to dig deeper into this topic (have to finish this animation till august 26th). also there is not guarantee that the problem would not appear with this solution.

could you by chance leave a comment on the "reset" part? would this be helpful in my situation? if yes, why and how to use it - if not, why? did i try the right thang? was is that what you meant with "precomp" and time remap? if not, could you be please a little bit more specific?

regards, mark
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

For the "reset", try replacing your line that calculates y with this:

y = rate * timeToFrames(time)%height;

Dan
Mark Antonio
Posts: 4
Joined: August 4th, 2009, 10:51 am

YESSSS!!!! as supposed this solved the problem. thanks alot, dan! could you by chance leave a short explanation why this change helps or what it does? i would really like to understand this thing to adopt it into further situations.

regards, mark
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

The % (modulus) operator performs a division but keeps only the remainder. So, say your layer height is 480. As rate*timeToFrames(time) goes from 0 to 479.999..., % has no effect. But as soon as rate*timeToFrames(time) gets to 480 the result gets reset to 0. Let's say rate*timeToFrames(time) is 600. Then 600%480 = 120 (600 divided by 480 is 1 (thrown away) with remainder 120 (result)). Hope that makes sense.

Dan
Mark Antonio
Posts: 4
Joined: August 4th, 2009, 10:51 am

it does! once again thanks alot! :-)
Post Reply