Activity › Forums › Adobe After Effects Expressions › How to raise the movement of a layer dynamically?
-
How to raise the movement of a layer dynamically?
Posted by Mark Antonio on July 15, 2009 at 9:09 pmhi folks,
i am new to expressions and working on a small car animation with the view point inside the car on the driver’s seat.
for creating the impression of the car driving i decided to animate the road. i created the ground and 3 white stripes as there are in real life to devide the road in the middle. a first animation with 2 keyframes for the first stripe and 2 expressions for the others setting them to follow the first with a short delay works fine. but since the car’s speed is raising i need the movement speed of the stripes to raise too.
how can i dynamically raise their speed? i head the idea of using a slider. but could not get something working outta it.
could you pros please help me with some noob understandable solutions? mabe my current way is too much complicated. any suggestions are much appreciated.
regards,
mark antonio
Mark Antonio replied 17 years, 1 month ago 2 Members · 5 Replies -
5 Replies
-
Kevin Camp
July 16, 2009 at 2:19 pmi think i would have tried creating the stripe animation with a single solid and 3 masks to create the lines. then used the offset effect to create the movement.
with offset, when you animate the offset point, as one line moves off the bottom edge of the solid, it will start to re-draw at th eto pof the solid, creatign the sort of looping amimation that you are looking for. you could then use a simple expression and slider control to increase/decrease speed of the animation.
just add a slider expression control to the solid and try an expression like this for the offset point:
rate = effect(“Slider Control”)(“Slider”);
value + [0, rate * timeToFrames(time)];you can then keyframe the ‘rate’ slider to make the rate increase or decrease as needed.
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Mark Antonio
July 16, 2009 at 7:05 pmhello kevin,
thanks for your reply. i basically understand your idea. but i somehow dont understand the effect. i set up what u suggested:
1 stripe of width 30px reaching from comp top to comp bottom
3 masks with each of it having a width of comp’s width and a 100px height arranged from top to bottom with equal spaces of 80px between each of em so it seems there are 3 stripes laying around.then i added the distortion>offset effect to the stripe layer and set one keyframe at the very beginning of the movie and one at the very end it to change the “Shift Center To Value” property. KF one hast the inital value of 288 and KF two i have a value of 2000. this workes but somehow strange. as i dont really understand the principle of this effect and the ae help also does not really help i dont know how to correctly set all up.
could you probably explain it in more detail to me or tell me where i can find a good explanation on how to use this effect? i am a beginner and not very experienced with ae’s expressions.
regards, mark
-
Kevin Camp
July 17, 2009 at 12:57 pmhi mark,
the offset effect is very similar to the offset filter in photoshop. it shifts the contents of a layer, but within the layer itself.
as it shifts the contents of the layer (by contents i mean what you see within the layer) it repeats what is moving off the layer on a given side onto the opposite side. so in your example, as one line moves off the bottom of the layer, it re-appears at the top of the layer, creating a continuous looping movement which seeemed like what you were after.
rather than using keyframes for movement, you can use an expression (actually you can keep the keyframes, the expression will override them). to add an expression, select the centerpoint property and choose animation>add expression. this will open an expression field for the property. for starters, add this expression:
rate = 5; //movement in pixels per frame
x = 0;
y = rate * timeToFrames(time);
value + [x, y]to make it easier to follow, i broke it up a bit. the first line sets a variable’ ‘rate,’ which is how much the offset will move with each frame, in thsi cas 5 pixels every frame.
the next two line separate x and y to make it easier to see that those were simple coordinates. x is jsut set to 0, while y is set to take the frame number and multiply it by the rate value, thus creating the movement on the y axis.
the last line just take the current value that is set for the centerpoint and adds the new x & y values that the expression creates. since x is 0, there is no x movement, so the offset will only occur on the y axis.
since you want to be able to animate the offset, you’ll need to add a control that can be keyframed. to do that, you’ll want to add the expression control effect called slider control. this will allow you to keyframe a value change for the rate. to link the rate variable to the slider, you can highlight the value of ‘5’ in the expression and use the expression pickwhip and drag it to the slider value (by default is 0.0). you expression would now look something like this:
rate = effect(“Slider Control”)(“Slider”);
x = 0;
y = rate * timeToFrames(time);
value + [x, y]once that is done, any value that you set with the slider will be the offset rate… if you set the slider value to 20, the offset will be 20 pixels per frame. if you keyframe the slider value to go from 0 to 20 over one second, then the offset value will increase from 0 to 20 over on second, creating an acceleration-like effect that you were looking for.
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Mark Antonio
July 20, 2009 at 12:28 pmGREAT THANG, Kevin!!! i finally got it and it works perfectly! 🙂 Thank you so much!
mark
-
Mark Antonio
August 2, 2009 at 6:39 pmi have to continue this topic as there appears to be a new problem with this animation.
i now have applied created animation as suggested and bound it to a slider that got keyframed. first keyframe having val 0, second 10 and third 30. up to the last keyframe the speed raises constantly as aimed. but at last keyframe the speed breaks down and runs at a quite lower level up to the end of the animation. i have absolutely no idea what this is cause by and need help to fix this. the code i use is:
rate = effect("Schieberegler")("Schieberegler"); // Bewegung in pixels pro frame
x = 0;
y = rate * timeToFrames(time);
value - [x,y]could you please help me again?
regards, mark
Reply to this Discussion! Login or Sign Up