ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random Movement between two set points

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ryan Shackelford
Random Movement between two set points
on Jun 9, 2015 at 6:32:46 pm

I'm trying to create a null that will move between two points based on a percent complete slider. This null will move hundreds of other layers. All of those layers will start at a set point and end near a set point based on whatever random number is given to them.

I don't want to use the expressions, start at x time and end at y time because I want to be able to animate back and forth.

My null animates from 0 to 100 over 2 seconds.
My Start value is set to 0. This should mean all of my layers start at 0 on the Z axis.
My "End value" is set to 2000. Meaning I want them to travel roughly 2000 on the Z.
I have a random Z movement slider set to 500. Meaning I want the hundreds of layers to end +- 500 from what my "End Value" is. All of the hundreds of layers should move at independently from each other, in other words I don't want them all to end at the same z depth.

I have put the expression below onto a few of the hundreds of layers position to test it out. I can't get the tStart or tEnd to start and stop on the % complete keyframes from my null. I thought if I was able to tell it, when cT equals 0 on the slider, then Start moving the layers. When cT equals 100 on the slider, then Stop moving the layers.

Floor Controls (Null Sliders)
% Complete: 0 to 100 slider (this is where my key frame animation would be)
Starting Z Depth: 0
Z Depth: 2000
Random Z Movement: 500

Other Layers:
zRandom=thisComp.layer("Floor Controls").effect("Random Z Movement")("Slider");
cT=thisComp.layer("Floor Controls").effect("% Complete")("Slider")/100;
StartVal=thisComp.layer("Floor Controls").effect("Starting Z Depth")("Slider");
EndVal=thisComp.layer("Floor Controls").effect("Z Depth")("Slider")+random(zRandom);
z = ease(time,tStart,tEnd,StartVal,EndVal);
value + [0,0,z]

Return to posts index

Walter Soyka
Re: Random Movement between two set points
on Jun 9, 2015 at 6:46:38 pm

This bit:

[Ryan Shackelford] "tStart=(cT=0);

... does not do what you think it does. You are assigning a value to cT here, then assigning the result of that assignation to tStart and tEnd.

Instead of looking at time (which I'm not sure you want to do anyway), why not look at value?

z = linear(cT,0,1,StartVal,EndVal)

Put the eases manually on the cT slider keyframes instead of in the expression.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

Return to posts index

Ryan Shackelford
Re: Random Movement between two set points
on Jun 9, 2015 at 6:52:51 pm

That is exactly what I was looking for. Thank you! I got so focused on one thing that I completely overlooked something easier right in front of me.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved