A 2D lookAt() function
Posted: October 21st, 2015, 7:47 am
For 2D, the lookAt() function in After Effects’ expression language doesn’t work as expected. When the looked-at point is below the looking-from point the direction reverses. This has been driving me nuts for years, so to save me having to go back to my high school trigonometry, I've created a function to replace the built-in lookAt() function:
More details on my blog.
Code: Select all
function lookAtMe(fromPt, toPt){
lkAt = lookAt(fromPt, toPt);
if (toPt[1] > fromPt[1]){
return 180-lkAt[1];
} else {
return lkAt[1];
}
}
//implement the function
p0= transform.position; //look from point
p1=thisComp.layer("some other layer").transform.position; //looked-at point
lookAtMe(p0, p1)