ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Move on local Axis Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nigi Lapan
Move on local Axis Expression
on Apr 13, 2018 at 11:33:23 am
Last 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?


Edit: working in 3D Space...

Return to posts index

Dan Ebberts
Re: Move on local Axis Expression
on 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])


Return to posts index

Nigi Lapan
Re: Move on local Axis Expression
on Apr 14, 2018 at 8:22:47 am

Hey Dan, thanks for your answer!,

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])

Return to posts index

Nikolaus Lapan
Re: Move on local Axis Expression
on Apr 15, 2018 at 3:35:43 pm

Nevermind, I found a solution to my problem: I added a 3d Point effect on the master layer to store the Coordinates of its Upper right corner, then just linked the slave layers position to that...

Thanks for your Help :)

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved