FORUMS: list search recent posts

Reading distance from object

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hiski Suomela
Reading distance from object
on Feb 5, 2018 at 2:49:06 pm

Hey everyone!

I have a problem. I'm having an expression to read distance between two layers and changing the opacity of other of the layers with an ease.

My problem is that the distance is between the anchorpoints of the objects. I need somehow the "position" of the master layer to be the actual shape of that layer, not the anchorpoint position. I mean as I move the master layer, it changes the opacity around it, not only around it's anchorpoint.

Is this even possible or do I have to give up with this? Hope you guys can help. ☺

- Hiski

master = thisComp.layer("haka1");
beginOp = [0];
endOp = [100];
beginDistance = 300;
endDistance = 10;
distance = length(this.position, master.position);
ease(distance, beginDistance, endDistance, beginOp, endOp)


Return to posts index

Dan Ebberts
Re: Reading distance from object
on Feb 6, 2018 at 12:52:08 am

Try this:


master = thisComp.layer("haka1");
r = master.sourceRectAtTime(time,false);
p = master.toComp([r.left+r.width/2,r.top+r.height/2]);
beginOp = 0;
endOp = 100;
beginDistance = 300;
endDistance = 10;
distance = length(position, p);
ease(distance, endDistance, beginDistance, endOp, beginOp)



Dan



Return to posts index

Hiski Suomela
Re: Reading distance from object
on Feb 6, 2018 at 7:06:35 am

Hi, Dan! Thanks for your reply!

The code seems to act like the one I pasted here. The opacity still reacts to the anchorpoint of "haka1" but not the shape.

Some more info. I'm having a 4K 16:9 composition and the master layer I'm moving is a shape of ^. I'd like to have small squares (like big pixels) to change opacity depending on how close they are to that shape path. That means I also want the code to ignore the bounding box. Only to affect the shape of the layer.

Did I do something wrong?


Return to posts index


Hiski Suomela
Re: Reading distance from object
on Feb 6, 2018 at 7:13:45 am

EDIT:

Sorry. It doesn't affect depending on the position of the anchorpoint but still the position of the very center of "haka1".

So yeah, I'd need it to affect to the borders of the shape if that's even possible. :)


Return to posts index

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