ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

reTimed ease on triggered event

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Moritz Ritchson
reTimed ease on triggered event
on Nov 6, 2016 at 8:21:16 pm

Hi, I'm new but I was following the forums for quite some time now wich helped me a lot in the past.
Unforunately I found no solution for my actual "problem" by just searching the forum.

I would like to fade and scale in a layer if it hits a certain distance to the active camera wich works nicely so far, besides there is no ease happening ?
I suppose because the easy used to happen early and it jumps direct to its end value when triggered.

I also tried to create a loop, combined with an "if - query" wich was suggested solution in another post. For some reason, I got the same effect. No looping of the keyframes, instead jumping direct to its end value.

I've absolutely no idea on how to approach on this ?

Thanks for your help! Cheers

d = length(thisComp.layer("name").position[0,1,2] - thisComp.activeCamera.position[0,1,2]);
if (d&lt;=400)
{
easeIn(time,inPoint+0,inPoint+1,[15,15,15],[25,25,25]);
}
else
{
ease back ...
}


Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 7, 2016 at 8:32:27 pm

I think I found a helping post by dan on the motionscript side about checking conditions in reverse.

Unfortunately it does not cylce through the loop ?

Please, help.

//http://www.motionscript.com/design-guide/audio-count.html

threshold = 800;

above = false;
frame = Math.round(time / thisComp.frameDuration);
n = 0;

while (frame >= 0){
t = frame * thisComp.frameDuration;

loc = thisComp.layer("Null 1").transform.position.valueAtTime(t);
cam = thisComp.layer("Kamera 1").transform.position.valueAtTime(t);

delta=sub(loc,cam);
distance=Math.round(length(delta));

if (above){
if (distance > threshold){
above = false;
}

}else if (distance &lt;= threshold){
above = true;
n++;
}
frame--
}

"distance: " + distance + "\r" + "above: " + above +"\r" + "result: " + n + "\r" + "frame: " + frame;


Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 7, 2016 at 8:34:25 pm

I just would like to know at wich time my condition comes true and to "save" it for later use. I hope this is understandable.

Thanks a lot


Return to posts index


Dan Ebberts
Re: reTimed ease on triggered event
on Nov 7, 2016 at 10:40:13 pm

I think the one you need to model it on is this one:

http://www.motionscript.com/design-guide/audio-trigger.html

you wouldn't need the bottom two pieces (below the last curly bracket }). Instead, you'd want to add your ease statement that would look something like this

ease(t,0,yourEaseDuration,yourValue1,yourValue2)

I'd do it for you, but I'm pretty tied up at the moment.

Dan



Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 8, 2016 at 6:36:06 am

That's excatly what I used as a base ?
As I'm quite new to expressions I use the last row as a debugger in a Text Layer to check the values over time.

What I expect to get delivered by the expression is the time where the condition becomes true, or the other way around. Then I would like to use these value as start point of my ease.

startPoint = (value by expression)

ease(t,startPoint,startPoint+1,yourValue1,yourValue2)

Thanks a million.


Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 8, 2016 at 5:10:17 pm

Was on the wrong link before ?
Now with the right one I altered the code but still does not work ?

threshold = 800.0;

above = false;
frame = Math.round(time / thisComp.frameDuration);
while (true){
t = frame * thisComp.frameDuration;
n = thisComp.layer("Null 1").transform.position.valueAtTime(t);
c = thisComp.layer("Kamera 1").transform.position.valueAtTime(t);
delta=sub(n,c);
dist=Math.round(length(delta));
if (above){
if (dist &lt; threshold){
frame++;
break;
}
}else if (dist >= threshold){
above = true;
}
if (frame == 0){
break;
}
frame--
}
if (! above){
t = 0;
}else{
t = time - frame * thisComp.frameDuration;
}
t;


Return to posts index


Dan Ebberts
Re: reTimed ease on triggered event
on Nov 8, 2016 at 5:25:33 pm

Try this one:


L1 = thisComp.layer("Null 1");
L2 = thisComp.layer("Kamera 1");
threshold = 800;
trig = false;
for (f = timeToFrames(time); f >= 0; f--){
tCur = framesToTime(f);
d = length(L1.toWorld(L1.anchorPoint,tCur),L2.toWorld(L2.anchorPoint,tCur));
if (trig && (d > threshold)) break;
if (d <= threshold) trig = true;
}
t = trig ? time - framesToTime(f+1) : 0;



Dan



Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 8, 2016 at 5:40:51 pm

Thanks a lot for your help - sadly I get an error which says, there is no method or property on the camera named "anchorPoint".

But I got it working by trying around with audio trigger your scipt. It does what it sould do - at least half of it.

Next step would be, an ease the other way around when the distance is over 800 / threshold again.

Thanks again. You're doing an awesome job.

threshold = 800.0;

above = false;
frame = Math.round(time / thisComp.frameDuration);
while (true){
t = frame * thisComp.frameDuration;
n = thisComp.layer("Null 1").transform.position.valueAtTime(t);
c = thisComp.layer("Kamera 1").transform.position.valueAtTime(t);
delta=sub(n,c);
dist=Math.round(length(delta));
if (above){
if (dist > threshold){
frame++;
break;
}
}else if (dist &lt;= threshold){
above = true;
}
if (frame == 0){
break;
}
frame--
}
if (! above){
t = 0;
}else{
t = time - frame * thisComp.frameDuration;
}
//"Frame: " + frame +"\r" + "FramesToTime: " + framesToTime(frame, fps = 1.0 / thisComp.frameDuration);
sPos = framesToTime(frame, fps = 1.0 / thisComp.frameDuration);

if (frame > 0)
{
ease(time,sPos,sPos+1,value,[25,25]);
}
else
{
value;
}


Return to posts index

Dan Ebberts
Re: reTimed ease on triggered event
on Nov 8, 2016 at 5:59:05 pm

Sorry. Try it this way:


N = thisComp.layer("Null 1");
C = thisComp.layer("Kamera 1");
threshold = 800;
trig = false;
for (f = timeToFrames(time); f >= 0; f--){
tCur = framesToTime(f);
d = length(N.toWorld(N.anchorPoint,tCur),C.toWorld([0,0,0],tCur));
if (trig && (d > threshold)) break;
if (d <= threshold) trig = true;
}
t = trig ? time - framesToTime(f+1) : 0;



Dan



Return to posts index


Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 8, 2016 at 6:15:40 pm

Perfect!

Could you also help me to do the trick the other way around? Update tCur with the frame when the value is bigger than the threshold again?

Thank you so much


Return to posts index

Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 9, 2016 at 1:56:24 pm

Me again, got stuck with same or similiar problem ?

I'm using the code from above to check at wich frame / time there is a layer marker on "P". (Wich is on frame 25 / 1 sec)
It starts counting the frames, but as soon as it detects the layer marker the frame counter jumps back to "0" ?

P = thisComp.layer("pointer");

n = 0;

if (P.marker.numKeys > 0)
{
n = P.marker.nearestKey(time).index;
if (P.marker.key(n).time > time) n--;
}


above = false;
frame = Math.round(time / thisComp.frameDuration);
while (true)
{
if (above)
{
if (n >= 0 )
{
frame++;
break;
}
}
else if (n &lt;= 0)
{
above = true;
}

if (frame == 0)
{
break;
}

frame--
}

"n: " + n + "\r" + "above: " + above + "\r" + "f: " + frame;


Return to posts index

Dan Ebberts
Re: reTimed ease on triggered event
on Nov 9, 2016 at 5:11:32 pm

What is it you're trying to accomplish? The time attribute for any marker is easily accessible. No need to loop through frames.

Dan



Return to posts index


Moritz Ritchson
Re: reTimed ease on triggered event
on Nov 9, 2016 at 6:58:19 pm

Figured it out ?

Could you also help me to do the trick the other way around? Update tCur with the frame when the value is bigger than the threshold again?

Thank you so much

N = thisComp.layer("Null 1");
C = thisComp.layer("Kamera 1");
threshold = 800;
trig = false;
for (f = timeToFrames(time); f >= 0; f--){
tCur = framesToTime(f);
d = length(N.toWorld(N.anchorPoint,tCur),C.toWorld([0,0,0],tCur));
if (trig && (d > threshold)) break;
if (d &lt;= threshold) trig = true;
}
t = trig ? time - framesToTime(f+1) : 0;


Return to posts index

Dean Snider
Re: reTimed ease on triggered event
on Dec 13, 2016 at 2:55:22 pm

Got it working, except one little thing where I could need some help. Again.

Setup:
There is a camera, a null and a dummy object in the scene. On the camera is an animation wich reduces the distance to the null, stays there for a time and moves back to it's origin. The code is embedded in the scale attribute of the dummy object, wich is a solid scaled to 50%.

Working
When the camera goes below a certain distance (threshold = 800) to the null, the dummy object eases down (val =25) to 25% scale in 15 frames (dFrames = 15)
When the camera get's over the threshold again, the dummy eases back.

Not Working
I'm not getting the end values (of first ease) automaticly - so I set them manually (v = [25,25]. Otherwise the original values of 50% are taken for the ease.

Thank you for your help again!

threshold = 800;
dFrames = 15;
val = 25;

above1 = false;
above2 = false;
frame_enter = 0;
frame_exit = 0;
frame = Math.round(time / thisComp.frameDuration);

while (true)
{
t = frame * thisComp.frameDuration;
n = thisComp.layer("Null 1").transform.position.valueAtTime(t);
c = thisComp.layer("Kamera 1").transform.position.valueAtTime(t);
delta=sub(n,c);
dist=Math.round(length(delta));

if (above1)
{
if (dist > threshold)
{
frame++;
frame_enter = frame;
break;
}
}
else if (dist&lt;= threshold)
{
above1 = true;
}

if (above2)
{
if (dist &lt; threshold)
{
frame++;
frame_exit = frame;
break;
}
}
else if (dist>= threshold)
{
above2 = true;
}

if (frame == 0)
{
break;
}
frame--
}

dur = (dFrames*thisComp.frameDuration)

enter = framesToTime(frame_enter, fps = 1.0 / thisComp.frameDuration);
exit = framesToTime(frame_exit, fps = 1.0 / thisComp.frameDuration);

if (frame_enter > 0 && frame_exit ==0)
{
ease(time,enter,enter+dur,value,value-[val,val]);
}
else if (frame_exit > 0 && frame_enter ==0)
{
v = [25,25];
//v = thisLayer.transform.scale.valueAtTime(exit-1);
ease(time,exit,exit+dur,v,v+[val,val]);
}
else
{
value;
}


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]