ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Look At" Expression???

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
cow
Michael Cavallaro
"Look At" Expression???
on Jun 15, 2008 at 4:55:22 am

I know I've seen this somewhere before but I can't find it for the life of me. Does AE have a "Look At" controller similar to a 3D program?

Basically, I need to have one end of a line follow another layer while the other end stays "stuck" to some text.

There's probably many ways to do this so any suggestions would help. I was thinking that the anchor point of the line would be at the "fix point" and the line would just rotate to continually face the moving layer. This doesn't account for the size of the line changing when the object moves to-away but it will do.

Thanks in advance...

MikeC


Return to posts index

cow
Mike Clasby
Re: "Look At" Expression???
on Jun 15, 2008 at 6:50:16 am

1) "look At" goes on a 3D layer's Orientation like this:

lookAt(thisComp.layer("my text").position, position)

Since look at is not really Point At, it more like Orient Toward or face At, you need to scrub the x, y or z to see what gets it pointing at the layer you want. Often it's Y rotation at 90 degrees.

look At can be a bit tricky, at least for me.

2) Anyway, I think it's easier to connect two layers with the beam effect, like in this mod of a Dan Ebberts technique:

So add the Beam effect to a 2D Black Solid (make it big enough to let the beam stretch as far as needed). To the two 3D layers you want to connect (or have a line pointing from one to the other, use this expression for the Beam's "Starting Point" (Copy the expression, Alt-click the Starting Point Stop watch, Paste):

target = thisComp.layer("my text");
fromComp(target.toComp(target.anchorPoint));

and this expression on the beams' Ending Point:

target = thisComp.layer("My Other Layer");
fromComp(target.toComp(target.anchorPoint));

Obviously you need to put the correct layer names in for "my text" and "My Other Layer".

Adjust the beams length and location by tweaking the Beam's Length and Time parameters. You can also adjust the starting and ending thickness.

This setup is just an illusion, adapted for 2D Beam, from Dan's tut for 2D Corner Pin, from here:

http://www.motionscript.com/design-guide/threeD-corner-pin.html

But like Dan says it maintains the illusion even with a moving Camera. By an illusion I mean the beam is on a 2D layer, not 3D, it just looks 3D. Along those lines, the only thing that really messes this up is if you mistakenly change the solid layer's position, so that it's not right in front of the camera, then the beam can seem cutoff at one end. So it's not a bad idea to maybe even lock the layer once you have the beam adjusted the way you want. This setup works for me in a quick test.

If this doesn't do what you want, holler.








Return to posts index

cow
Michael Cavallaro
Re: "Look At" Expression???
on Jun 15, 2008 at 7:07:10 am

PERFECTO!!!!

This is even better than I was hoping for. The beam technique is a great idea.

Thanks a million!

MikeC



Return to posts index


cow
Mike Clasby
Re: "Look At" Expression???
on Jun 15, 2008 at 7:08:44 am

After thinking about it, methinks the 2D solid with beam on it only needs to be comp size.



Return to posts index

stephen dixon
Re: "Look At" Expression???
on Oct 23, 2015 at 5:25:55 am

It has always bugged me that there's not a good 2D lookAt function in AE, so I made one:
http://blob.pureandapplied.com.au/lookat-me/

It can be used to create a better Auto-Orient function too.

Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria


Return to posts index

ion popescu
Re: "Look At" Expression???
on Jul 11, 2019 at 8:42:58 pm

This is exactly what I was hoping to find. It's GREAT!

Thank you and God bless you

If it look's good, It's good


Return to posts index


Patrick Grossien
Re: "Look At" Expression???
on Jun 8, 2020 at 10:07:21 am
Last Edited By Patrick Grossien on Jun 8, 2020 at 10:50:54 am

I wanted to do the same thing, but since I needed it to show DoF, the common workarounds didn't cut it for me.

My solution is a rectangular shape 3D layer which uses length and lookAt to connect the dots - no pun intended 😉 It's basically nice cos / sin math packed into readily available commands.

Rectangle path / Size:
distance = length(thisComp.layer("Layer1").transform.position, thisComp.layer("Layer2"). transform.position);
[20,distance]

I used a slider on that same layer to control the width (x) value instead of a fixed value:
[effect("Stroke")("Slider")[0],distance]
Rectangle path / Position:
posDiff = content("Rectangle 1").content("Rectangle Path 1").size[1]/2;
[0,posDiff]

Transform / Position:
thisComp.layer("Layer1").transform.position
Transform / Orientation:
lookAt(thisComp.layer("Layer1").transform.position, thisComp.layer("Layer2").transform.position)

Then in my example, the circles are auto-oriented towards camera to look like spheres.



The problem I'm having, is that the rectangle should auto orient towards camera in width only. Because right now, depending on the viewing angle, the lines look different in size/width because of the 3D distortion of the flat layer. Basically, I believe, that I would only need to auto-orient the Y-rotation for it to work, but Dan's script doesn't work for me here, which is probably because of the script in the orientation parameter....






Return to posts index

Patrick Grossien
Re: "Look At" Expression???
on Jun 8, 2020 at 10:52:02 am
Last Edited By Patrick Grossien on Jun 8, 2020 at 10:07:34 pm

It seems, that Dan's update to the script which I found here:
https://forums.creativecow.net/docs/forums/post.php?forumid=227&postid=1203...

seems to work. Weirdly enough I tried that out earlier and then it didn't work. Don't know what I did in between anymore 😃

If anybody wants to have the Comp, just let me know.


Return to posts index

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