Activity › Forums › Adobe After Effects Expressions › control the velocity with expressions
-
control the velocity with expressions
Posted by Adrian Germain on September 18, 2006 at 4:39 pmHi. How can i control the velocity of a, let’s say position of a layer with expression. I mean, if a have already a moving path can i change the speed of the movement with an expression? Thanks.
Dan Ebberts replied 19 years, 8 months ago 2 Members · 5 Replies -
5 Replies
-
Dan Ebberts
September 18, 2006 at 5:23 pmIt depends on exactly what you’re trying to do. If you have a keyframed movement and you want it to go twice as fast, for example, you could use an expression like this:
valueAtTime(time*2)
If you want to manipulate the velocity as the layer moves, that’s a different story and requires a more complicated expression.
Another alternative is to turn on time remapping and apply an expression to that property.
Like I said, it depends on what you’re trying to do. 🙂
Dan
-
Adrian Germain
September 18, 2006 at 6:29 pmHi Dan, thanks for the post.
Look, i want to control the velocity of motion for a blob.
I want a random motion with an expression and the speed to be controlled by a slider of an audio amplitude, let’s say.So,I tried to apply to position of a null (Null6) this one (from motionscript.com :)):
segDur = .5;// duration of each “segment” of random motion
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(minVal,maxVal);
seedRandom(seed+1,true);
endVal = random(minVal,maxVal);
ease(time,segStart,segStart + segDur, startVal, endVal);After i use for the position of a blob:
s=thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”)/10
thisComp.layer(“Null 6”).transform.position.valueAtTime(time+s)Now is pretty close but it’s still moving where is now sound so i dont know how to get it.
Thanks for any advice. -
Dan Ebberts
September 18, 2006 at 10:20 pmOK – give this a try. “spd” sets how fast it tracks the null.
spd = .05;
level = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
accum = 0;
f = Math.round(time/thisComp.frameDuration);
for (i = 0; i <= f; i++){ t = i*thisComp.frameDuration; accum += level.valueAtTime(t); } thisComp.layer("Null 6").transform.position.valueAtTime(accum*spd); Dan -
Adrian Germain
September 20, 2006 at 2:45 pmThanks a lot Dan. Now it’s pretty close to what i wanted to do.I thought that is something around accumulation.
But i’m thinking to refine more the expression and what is bothering me is the constant velocity of the null directed by “segdur” parameter. So i want to fix a minimum for the sound level to change the seed of the randomness. It means, when the music is loud it changes the direction and go fast. When is low it continue in the same direction and it’s going slowly. Any advice? -
Dan Ebberts
September 20, 2006 at 8:15 pmI can’t see any easy way to do it. It would be a completely different algorithm. The current algorithm is based on picking a random target position and it’s easy for the expression to make sure that it’s within the boundaries of the comp. What you’re talking about sounds like picking a random direction and since the expression doesn’t know how long it’s going to be moving in that direction, it can’t guarantee that the object stays within the comp.
I’m sure it’s solvable, but unfortunately, I don’t have time to do it.
Dan
Reply to this Discussion! Login or Sign Up