Page 1 of 1

Advanced position parenting

Posted: August 25th, 2018, 6:25 pm
by nikto
Hi, I'm starting to study expressions and my problem is not related to a motiongraphic project. It's just a situation I created that I'd like to control.
What I'm working on is
- to parent the position of "layer B" to the position of "layer A" without losing the position "layer B" has at the moment of parenting....
- to preserve the possibility to modify "layer B" position trough keyframes while it follows that it is linked to
- to unlink "layer B" position from the parent at frame 250 leaving it in the last position it was when the parent has left it

My situation is:
- 25 fps composition
- layer A -a 200px x 200 px square shape with a "wiggle(5,50)" applied to the position and a "time*100" loop rotation
- layer B - same shape as layer A but in a different position. No other animated properties

A the moment my expression for layer B position is this:

Code: Select all

a=thisComp.layer(index-1);
x=value[0];
y=value[1];
stop=250;
stoptime=framesToTime(stop);
ax=a.transform.position[0];
ay=a.transform.position[1];
ax0=a.transform.position.valueAtTime(0)[0];
ay0=a.transform.position.valueAtTime(0)[1];
ax250=a.transform.position.valueAtTime(stoptime)[0];
ay250=a.transform.position.valueAtTime(stoptime)[1];

if (time < stoptime){
  [x+ax-ax0, y+ay-ay0]
}else{
  [x+ax250-ax0, y+ay250-ay0]
}
Actually it works pretty good except for the fact that if I move the layer A position without setting keyframes layer B seems unlinked from it.
I obviously refer to the first 250 frames in which parenting is active. Layer B follows layer A wiggled position, It follows layer A movements through keyframes.. But if I move layer A position in a specific place I want it to start from it does not affect layer B position...
Can someone help me? Thanks

Re: Advanced position parenting

Posted: August 27th, 2018, 2:10 am
by gi-jones
Try putting this on Layer B's position:

Code: Select all

[
thisComp.layer("A").transform.position[0]+value[0],
thisComp.layer("A").transform.position[1]+value[1],
]

Re: Advanced position parenting

Posted: August 27th, 2018, 4:45 am
by nikto
Thank you vary much!!. As soon as I get home from work I test it!

Re: Advanced position parenting

Posted: August 27th, 2018, 11:53 am
by nikto
Sorry this afternoon I answered without reading your expression because I was messed up but now I don't understand what you mean by "try putting this on Layer B's position"...
On layer B position I already have the expression I wrote

Re: Advanced position parenting

Posted: August 30th, 2018, 11:46 am
by nikto
No ideas at all? Could you at least help me to understand how to define a "delta value" of a property when time is stopped and there are no keyframes? I mean... the key of my problem is that I need to parent "layer B position" to "layer A position" without losing "layer B native position" and making it responsive to the movements of layer A even when I'm just moving it with my mouse and I have no keyframes setted.

Layer B follows Layer A wiggled movements cause they're happening through time... and it follows Layer A movements if I set some keyframes to move layer A through time...

But in my case, problem is the begginning... at the beginning valueAtTime and value are the same... so if I move layer A .. layer B doesn't perceive any changes...

This is why my question is "How to define a delta, or a change in value, at zero time and without keyframes....."