ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Move on local Axis Expression

FAQ   •   VIEW ALL
 Move on local Axis Expression on Apr 13, 2018 at 11:33:23 amLast Edited By Nigi Lapan on Apr 13, 2018 at 1:02:58 pm

Hi Everyone!

I can't find out, how to move a solid on its local axis using expressions... I played with toGlobalVec but it didn't work for me... Can someone help please?

Thanks!

Edit: working in 3D Space...

 Re: Move on local Axis Expressionon Apr 13, 2018 at 4:04:07 pm

I'm not sure exactly what you're after, but if, for example, you wanted to move a layer 100 px along its local x axis, you could do it like this:

value + toWorldVec([100,0,0])

Dan

 Re: Move on local Axis Expressionon Apr 14, 2018 at 8:22:47 am

That worked for me, i'm not sure what i did wrong Yesterday... Thanks!

I have a follow up question though: is it possible, to move a layer on ANOTHER Layers local axis?

I have two solids in 3D Space, both of them have their anchor at 0,0,0. I want one layer to always be positioned at the Master Layers upper right corner. i'll post my code below. the problem with it is, that when i rotate the slave layer around its y-axis, it rotates around the Master Layers Anchor rather than its own... So i would like to try and move the Slave layer on the MASTER layers local x-axis.

How would you approach something like this?

```MasterLayer = effect("Master Layer")("Layer") MasW = MasterLayer.width MasterWidthPercent = MasterLayer.transform.scale[0]; MasterWidthPixel = MasW/100* MasterWidthPercent; Xs = transform.scale[0]; x =MasterLayer.transform.position[0] y = MasterLayer.transform.position[1] z = MasterLayer.transform.position[2]; [x,y,z] + toWorldVec([MasterWidthPixel/100* Xs ,0,0]) ```