ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Parenting Position Retaining Orig Position of Child

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
andrew halasz
Parenting Position Retaining Orig Position of Child
on Jun 8, 2012 at 3:58:02 pm

I've search for a reference to this specific question for quite a bit of time. I seems rudimentary, but I would love some closure.

I have to objects on a comp (layer "A" and layer "B")- I would like to use an expression to parent the position of the one to the other (A as parent, B as child). I've been unable to find an expression that does not change the original position of B when entering the expression.

It either places B directly at the same position as A with this expression

thisComp.layer("A").transform.position

or displaces B to a different position using this expression

L = thisComp.layer("A");
fromWorld(L.toWorld(L.thisComp.layer("A").position))

Both of course then allow B to then follow A's position, but I'm curious if there is a way to have B remain its orig position.

My work around has been to add +value to the expression and move B back to its orig position.

Any help would be greatly appreciated.


Return to posts index

Dan Ebberts
Re: Parenting Position Retaining Orig Position of Child
on Jun 8, 2012 at 7:21:12 pm

One way to do it is to add layer B's current position to the amount that Layer A has moved since time zero:

p = thisComp.layer("A").transform.position;
value + p - p.valueAtTime(0)


This won't do anything until you actually animate layer A's position though.

Dan



Return to posts index

andrew halasz
Re: Parenting Position Retaining Orig Position of Child
on Jun 9, 2012 at 4:06:51 am

Thanks Dan! Works Great!


Return to posts index


Gus Favoreto
Re: Parenting Position Retaining Orig Position of Child
on May 21, 2019 at 4:43:30 pm

Thank you Dan! I was looking for this answer for years.
I am trying to add a delay on this expression but is not working. Should I add at the end on valueAtTime(0)?

Thank you!
Gus


Return to posts index

Dan Ebberts
Re: Parenting Position Retaining Orig Position of Child
on May 21, 2019 at 5:41:05 pm

It would depend on what you're doing exactly, but this would be my guess:


delay = .25;
p = thisComp.layer("A").transform.position;
value + p.valueAtTime(time-delay) - p.valueAtTime(0)


Dan



Return to posts index

Gus Favoreto
Re: Parenting Position Retaining Orig Position of Child
on May 21, 2019 at 8:51:57 pm

YES! Perfect!

Thank you Dan!


Return to posts index

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