ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression to point a layer Rotation towards null

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mac Lad
Expression to point a layer Rotation towards null
on Oct 4, 2017 at 6:34:21 pm

Hello Gurus,
I m trying to figure out an expression to point my layer (which is a shadow in it of dots) Rotation toward null object as I need to animate the null from left to right.

1.png
This is my Main Comp with dots and Shadows

2.png
this is my shadow layer (All shadow are seperated)

Anchor point of Shadow Layers is at the upper left corner of each layer so that it can be rotated around dots

Is guys there any way to point this layer towards null object animating as I defined above or anywhere in the comp ?


Return to posts index

Walter Soyka
Re: Expression to point a layer Rotation towards null
on Oct 5, 2017 at 10:06:46 am

Use this expression on the rotation properties of your shadow layers. Change the word CONTROL here to match the name of your shadow-caster layer.

lookAtLayer = "CONTROL";
L = thisComp.layer(lookAtLayer);
p = L.toComp(L.anchorPoint);
d = thisLayer.toComp(anchorPoint) - p;
d[0] = (d[0]==0)?1:d[0];
rotation + radians_to_degrees(Math.atan(d[1]/d[0])) - 90*d[0]/ Math.abs(d[0]);


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Mac Lad
Re: Expression to point a layer Rotation towards null
on Oct 5, 2017 at 10:21:53 am

That really works man !! Awesome, thanks for the help.
I did try with dan's shadow expression but that didn't help me for the separate layers


Return to posts index


Mac Lad
Re: Expression to point a layer Rotation towards null
on Oct 8, 2017 at 8:41:42 am

Is it possible to change the scale of the shadow layers depending upon the distance from the null?
for instance:
if my Control layer is at the top left corner then the scale of shadow layer at bottom right corner will be zero but the scale of the closest layer to the source is 100%. Just like a ramping


Return to posts index

Walter Soyka
Re: Expression to point a layer Rotation towards null
on Oct 9, 2017 at 9:29:47 am

[Mac Lad] "Is it possible to change the scale of the shadow layers depending upon the distance from the null?"

Sure.

Add four Slider Control effects to your CONTROL layer, and name them and set their values as follows:
minDistance 0
minDistanceScale 100
maxDistance 1000
maxDistanceScale 0

The put this expression on the scale property of your shadow layers:
L = thisComp.layer("CONTROL");
maxDistance = L.effect("maxDistance")("Slider");
maxDistanceScale = L.effect("maxDistanceScale")("Slider");
minDistance = L.effect("minDistance")("Slider");
minDistanceScale = L.effect("minDistanceScale")("Slider");

distance = length(L.toComp(L.anchorPoint), thisLayer.toComp(thisLayer.anchorPoint));
scaleFactor = linear(distance, minDistance, maxDistance, minDistanceScale, maxDistanceScale) / 100;
[value[0] * scaleFactor, value[1] * scaleFactor]


Again, update the name CONTROL as necessary for your comp. You can adjust the values of the slider controls to tune the effect to your liking.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Mac Lad
Re: Expression to point a layer Rotation towards null
on Oct 10, 2017 at 12:39:20 pm

Its working awesome!!
thank you so much for the help... Ur genius :)


Return to posts index

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