ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Getting Velocity from a layer that's parented to a layer, that is also parented.

FAQ   •   VIEW ALL
 Getting Velocity from a layer that's parented to a layer, that is also parented. on Jun 25, 2019 at 9:27:38 am

Hi,

If A is parented to B, I know how to get B's velocity,

However, if A is parented to B and B is parented to C, and if C is the layer that has animations, is there any way I can get B's velocity's value?

Using C's velocity doesn't work for me. It needs to be B, as C is a IK handle which drives movements of B, which is the midjoint.

 Re: Getting Velocity from a layer that's parented to a layer, that is also parented.on Jun 26, 2019 at 10:32:32 am

I would split the problem into two parts. First make another null layer and for position use a toWorld() or toComp() expression that references your layerB.
Then in another expression get the velocity of that null layerâ€™s absolute position

 Re: Getting Velocity from a layer that's parented to a layer, that is also parented.on Jul 3, 2019 at 5:56:17 am

Could you explain the part about "make another null layer and for position use a toWorld() or toComp() expression that references your layerB"?

how do I get it to reference to layerB if:
1. parenting to layerB doesn't inherit any position change, as layerB is a child of another parent, which doesn't give LayerB position change in the first place?
2. pickwhipping position to layerB also doesn't inherit any position change?

Thanks!

 Re: Getting Velocity from a layer that's parented to a layer, that is also parented.on Jul 9, 2019 at 2:36:38 pm

Hi Meng,

it'll work because this is precisely what the layer space transform functions such as toWorld() are designed for, to bypass the relative position (to parents, to scaling etc.) and get the raw position in 2D or 3D space.

The confusing part is you should not use it like this:
toWorld(l.position);

You take a point on your desired layer, it could be [0,0] or the anchorPoint, or anything, and you ask where in the 3D world that point is (toWorld), or at what 2D pixel (toComp) of the comp it is.
You call it as a method of the layer you're interested in

for example:

l=thisComp.layer("layerB");
l.toWorld(l.anchorPoint);

add that expression to the position of a null,

then get the velocity of this new null's position inside your expression with

thisComp.layer("Null 1").transform.position.velocity;

That will hget the post-expression result.