ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Making shape layer rotate to follow a null's position

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tom NicholsMaking shape layer rotate to follow a null's position
by on Apr 23, 2015 at 10:45:51 pm

Hi

I need to use and expression to create an animation of a magnetic field attraction. So i have a series of small rectangle shape layers and would like them to follow a null around the screen always pointing at it.

I want the rectangles to rotate on there own anchor point towards the null.

I figured it would be something equivalent to a point of interest that i could attach to the null and therefore create the attraction.

Like this magnet style:


If I could have a couple of pointers that would be great.

Thanks,
Tom


Return to posts index

Frank FeijenRe: Making shape layer rotate to follow a null's position
by on Apr 24, 2015 at 12:32:25 pm

Have a 'look at':
https://forums.creativecow.net/thread/227/10502


Return to posts index

Tom NicholsRe: Making shape layer rotate to follow a null's position
by on Apr 25, 2015 at 4:00:53 am
Last Edited By Tom Nichols on Apr 25, 2015 at 4:01:56 am

Thanks Frank for that but it doesnt quite fit my needs.

This is my base equation:

Line = length(toWorld(anchorPoint), thisComp.layer("Null 1").transform.position);
delta = toWorld(anchorPoint) - thisComp.layer("Null 1").toWorld([0,0,0]);
radiansToDegrees(Math.atan2(delta[0],-delta[1]))

But i need it to react so that the further away it is from the X and Y axis the more accurate the direction of line is. And vice versa.

So i extended it to this:

YNull = length(toWorld(anchorPoint), thisComp.layer("Null 1").transform.yPosition);
XNull = length(toWorld(anchorPoint), thisComp.layer("Null 1").transform.xPosition);
Line = length(toWorld(anchorPoint), thisComp.layer("Null 1").transform.position);
delta = toWorld(anchorPoint) - thisComp.layer("Null 1").toWorld([0,0,0]);
radiansToDegrees(Math.atan2(delta[0],-delta[1]))*(Math.atan2(ease(YNull,740,850,3,1), ease(XNull,390,500,3,1)))

But now it will not follow my Null layer correctly. I will attach a picture below of both expressions results.

You may notice a grey opacity and that is where the lines should be to fit the design.

BASE EXPRESSION:

EXTENDED:


Return to posts index

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