ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Parent to an object in another Comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Johan Nordström
Parent to an object in another Comp
on Jul 20, 2011 at 10:07:24 am

Hi!

I'm so new att expressions, and i'm sure this has been up on the forum before.. but im having a hard time finding the answer.
Here we go.

I want a pre-composed shape layer to parent to a layer in the original composition. I want it to move and scale exactly like the original image but in the pre-comp.

thnx.


Return to posts index

Greg Burrus
Re: Parent to an object in another Comp
on Jul 20, 2011 at 2:57:59 pm

If I understand you correctly you just want to know how you connect values between comps.

If that is it you can drag one compositions timeline panel above the other by clicking and dragging the tab above until you see the blue shapes that tell you where you are placing it.

Then you can just pick whip the values from one composition to the other.

If you happen to have expression controllers you can lock the effects panel with the lock in the tab then open the other composition and pick whip the values.

or you can just type the code below

hope this helps

greg

comp("Comp name").layer("your layer name").value

http://mogra.g2bproductions.com/ - Blog
http://g2bproductions.com/ - Portfolio


Return to posts index

Johan Nordström
Re: Parent to an object in another Comp
on Jul 20, 2011 at 3:58:32 pm

Yes!

Thank you!
I didnt think of that.. it was sooo easy...
Thank you so much!


Return to posts index


Pete Burges
Re: Parent to an object in another Comp
on Feb 11, 2019 at 10:51:23 pm

Here's a head scratcher:

Is it possible to parent a layer to a layer in another comp which is itself a child of another layer?

I know how to 'parent' position by referencing the anchor point with this expression (below),

but that doesn't affect rotation or scale. Does anybody know a way of doing that...?

Thanks,

Pete

target = thisComp.layer("target");
target.toComp(target.anchorPoint);


Return to posts index

Oleg Pirogov
Re: Parent to an object in another Comp
on Feb 12, 2019 at 3:41:16 am

In general, rotation and scale can be retrieved through observing the transformation of unit vector from child vector space to comp's vector space.
I.e.:

child = thisComp.layer("Child Layer")

//unit vector projection
uVecProj = child.toComp([1,0])-child.toComp([0,0])

//this gives Scale
scale = 100*length(uVecProj);

//this gives Rotation angle in [0, 360] degree range
arcSin=Math.asin(length(cross(normalize(uVecProj), [1,0])))

var angle = 0;
switch (arcSin>=0){
case true:
angle = radiansToDegrees(Math.acos(dot(normalize(uVecProj), [1,0])));
case false:
angle = radiansToDegrees(2*Math.PI - Math.acos(dot(normalize(uVecProj), [1,0])));
}

angle;


On daily basis though, I would rather get Scale by manually multiplying consequent Scale transformations of a given parent-child structure and Rotation - by adding Rotation transformations.

Or just recreate the whole parent-child structure in another comp with nulls, directly linking nulls' parameters to their prototypes' parameters.


Return to posts index

Pete Burges
Re: Parent to an object in another Comp
on Feb 12, 2019 at 4:22:05 am

Thank you so much for your detailed response, Oleg...!
I have to admit a lot of that is over my head...I will have to go through it line by line several times until I understand it properly(I'm not really a script guy, I'm an animator who dabbles).
In the end I made a workaround by using the anchor point to track position of the child, and then just taking the rotation and scaling from the parent object. Seems to work OK.


Return to posts index

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