-
Access to the time and the duration of value.
Hi there,
despite a hunt of expressions in the forum ( thank you dear Dan Ebberts)
I can’t achieve to access the duration of a value.The short story:
My SQUARE is moving withtwo arrows on left and right side, i want their animations switch to on when the SQUARE moves in their direction
and when it changes in the opposite the arrows scale down in 2 seconds and the opposite arrow switch to on,etc…No doubts that many parts of my following process is unificient so please correct me.
The long story:
A SQUARE is animated with a wiggle:seedRandom(1);
freq = 0.2;
amp = 300
loopTime = 5;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
ease(t, 0, loopTime, wiggle1, wiggle2)Two slider control are applied to the square with an
expression to determine changes in the direction of the SQUARE.Slider DIRECTION:
delta = thisComp.frameDuration;
tolerance = 0.7;
mySquare=thisComp.layer("SQUARE");
v1 = mySquare.position.velocity;
angle1 = Math.atan2(v1[1],v1[0]);
v2 = mySquare.position.velocityAtTime(time-delta);
angle2 = Math.atan2(v2[1],v2[0]);if (Math.abs(angle1 - angle2) > tolerance) 0 else 100;
Slider NUMBER:
threshold=100;
direction= effect("DIRECTION")("Slider");
above = false;
frame = Math.round(time / thisComp.frameDuration);
n = 0;
while (frame >= 0){
t = frame * thisComp.frameDuration;
if (above){
if (direction.valueAtTime(t) < threshold){
above = false;
}}else if (direction.valueAtTime(t) >= threshold){
above = true;
n++;
}
frame--
}
n
Two Compositions: Left Arrow and Rigth Arrow are parented to the SQUARE.
I want the Arrow scale in 0 to 20 when the direction changes for the first time
then scale out 20 to 0 with a decay of 2 seconds when the direction changes again and so on.But I don’t achieve to determine the time of this change in the direction.
In addition when the direction occurs i would remap the time to synchronize the Arrow’s animation
(depending wether the direction goes to the left or to the right)At the moment i accomplish that with an expression on the Time Remap:
Left Arrow:number=thisComp.layer("SQUARE").effect("NUMBER")("Slider");
i=number%2;
if (i==0)
{0}
else
{1};
Right Arrow:number=thisComp.layer("SQUARE").effect("NUMBER")("Slider");
i=number%2;
if (i==0)
{1}
else
{0};But once again i dunno how to access to the time and the duration of direction changes for example between the 4th and the 5th
of my slider “NUMBER”. My Arrow animation stays fixed. 🙁I join the project if someone wants to take a look it would be easier to understand.
7655_squaredirection.aep.zipAny help would be gladly apreciated. Thanks in advance.
Benoit Kergosien