ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Layer points to another layer with delay?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Snyder
Layer points to another layer with delay?
on Jul 7, 2018 at 5:18:22 am

I'm using this code so that a layer rotates towards a parent.

Is there a way to add a delay in frames to the rotation?

L1 = thisLayer;
L2 = Null_01;
p1 = L1.toWorld(L1.anchorPoint);
p2 = L2.toWorld(L2.anchorPoint);
delta = p2 - p1;
follow = radiansToDegrees(Math.atan2(delta[1],delta[0]));


Return to posts index

Kalleheikki Kannisto
Re: Layer points to another layer with delay?
on Jul 7, 2018 at 8:37:56 am

A simple way to achieve this is to add another null which follows the position of the original null with a delay and calculate the rotation value based on the second null. Delay with valueAtTime():

delay = .25;
thisComp.layer("Null_01").transform.position.valueAtTime(time-delay);


Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Kevin Snyder
Re: Layer points to another layer with delay?
on Jul 15, 2018 at 3:20:03 pm

Thank you, Kalleheikki. That sounds like a good way to make it work. I appreciate it.

Kevin


Return to posts index


Alex Printz
Re: Layer points to another layer with delay?
on Jul 16, 2018 at 2:12:54 pm

This will take e.g. 99 frames (or whatever you set to t) and use the positions that the values were at at that time to calculate the delta. Adjust as necessary to get the result you want (maybe drop the t for L1(thisLayer)?


t = time-framesToTime(99);
L1 = thisLayer;
L2 = Null_01;
p1 = L1.toWorld(L1.anchorPoint,t);
p2 = L2.toWorld(L2.anchorPoint,t);
delta = p2 - p1;
follow = radiansToDegrees(Math.atan2(delta[1],delta[0]));


Return to posts index

Kevin Snyder
Re: Layer points to another layer with delay?
on Jul 19, 2018 at 2:55:37 pm

Alex,

Thank you for the expression. I appreciate it. It's nice to get it all on one layer.

Kevin


Return to posts index

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