FORUMS: list search recent posts

How to link with relative values?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mateo Mazzini
How to link with relative values?
on Oct 20, 2016 at 2:41:04 pm

I have one object with position and scale animated, and I want another object to follow the position of the first object but not the scale, is there a way to link the position of the second object to the position of the first but in a relative way, as if were the "parent"?. Because if I put "thisComp.layer("object1").transform.position", it copies the position of the first object, and I want it to retain it´s original position while following the parent.
I know I can do this with a null object in the middle, but I think there must be a workaround on this, and I just don´t know it.

thanks.

Matz


Return to posts index

Romain Cousin
Re: How to link with relative values?
on Oct 20, 2016 at 3:19:42 pm

I think you can write this expression on the position of your follower layer :

thisComp.layer("NAME OF THE "PARENT" LAYER").transform.position+value;

Freelance motion designer :
http://www.romaincousin.fr


Return to posts index

Dan Ebberts
Re: How to link with relative values?
on Oct 20, 2016 at 4:02:11 pm

Try this:

p = thisComp.layer('NAME OF THE "PARENT" LAYER').transform.position;
(p.value - p.valueAtTime(0)) + value;

Dan



Return to posts index


Romain Cousin
Re: How to link with relative values?
on Oct 20, 2016 at 4:22:15 pm

Nice! I really need to learn how to use valueAtTime...

Freelance motion designer :
http://www.romaincousin.fr


Return to posts index

Mateo Mazzini
Re: How to link with relative values?
on Oct 20, 2016 at 4:39:46 pm

Thanks a lot Dan! that does exactly what I needed.
Is there a way to go further and make this expression work when you link at the middle of an animation?.
I was playing with nearestKey(time) but I didn't accomplish anything so far.

Matz


Return to posts index

Dan Ebberts
Re: How to link with relative values?
on Oct 20, 2016 at 5:43:31 pm

If you wanted to attach to the parent at a particular keyframe, you could do it like this:


p = thisComp.layer('NAME OF THE "PARENT" LAYER').transform.position;
keyToStart = 2;
if (p.numKeys > (keyToStart-1)){
t = p.key(keyToStart).time;
if (time > t){
value + (p.value - p.valueAtTime(t))
}else{
value
}
}else
value


Or, it you wanted to be at a particular time, you could do this:


p = thisComp.layer('NAME OF THE "PARENT" LAYER').transform.position;
tStart = 2;
if (time > tStart)
value + (p.value - p.valueAtTime(tStart))
else
value



Dan



Return to posts index


Mateo Mazzini
Re: How to link with relative values?
on Oct 21, 2016 at 1:17:49 pm

these two codes are amazing! thanks a lot Dan!

Matz


Return to posts index

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