FORUMS: list search recent posts

# Making shape layer rotate to follow a null's position

FAQ   •   VIEW ALL
 Making shape layer rotate to follow a null's position 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

 Re: Making shape layer rotate to follow a null's positionon Apr 24, 2015 at 12:32:25 pm

Have a 'look at':

 Re: Making shape layer rotate to follow a null's positionon Apr 25, 2015 at 4:00:53 amLast 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]);

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]);

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: