FORUMS: list search recent posts

Getting position from first keyframe only

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mike Foran
Getting position from first keyframe only
on Dec 13, 2018 at 5:02:59 pm

I would like the position of one layer to match the position of another layer's first motion path keyframe. So object A would remain in the same place that Object B started it's motion. Is there an expression that can get the position value of just the first keyframe?


Return to posts index

Richard Garabedain
Re: Getting position from first keyframe only
on Dec 13, 2018 at 5:09:35 pm

Hmm..How new to after effects are you? I need to know before I can answer.. Im not sure I understand the problem...It seems like a simple copy and paste would work..but that must not be it because that is too simpe


Return to posts index

Mike Foran
Re: Getting position from first keyframe only
on Dec 13, 2018 at 5:18:21 pm

I'm pretty advanced actually. I'm looking for a dynamic solution. Not sure if explaining the issue helps, but I'm trying to use a light path to control the path of particles in Stardust. When you use a Motion node in Stardust to do this, it bases the emitter on the location of where the light's motion path starts. So if I move the starting position of the light, the the entire path of the particles shifts. I have to keep copying the starting point position of the light to the position of the emitter so the particles align to my light's path.

This is a pain in the butt. I thought if I could just have an expression that would automatically retrieve the position of the light's first keyframe for the position of the emitter, it might make this a lot easier to work with. I thought I understood it but I can't seem to write an expression that isn't broken.


Return to posts index


Marko Suto
Re: Getting position from first keyframe only
on Dec 13, 2018 at 5:25:59 pm

I'm no expert, but "valueAtTime" sounds like what you're looking for?

thisComp.layer(1).position.valueAtTime(1/x) /// x being your comp frame rate


Return to posts index

Mike Foran
Re: Getting position from first keyframe only
on Dec 13, 2018 at 7:49:30 pm

I think that will do for now but I was hoping for something that would identify the first keyframe and pull that value. From other posts it does involve valueAtTime and key(1) but I can't seem to figure the correct syntax. This is what I have so far, which does not work:


L = thisComp.layer("Motion Path A")
if (L.transform.position.numKeys > 1){
v1 = L.transform.position.valueAtTime(key(1));
}else{
L.transform.position
}


This gives me an error that "this property has no keyframe number 1" although it does. I think I'm just not addressing the layer properly?


Return to posts index

Walter Soyka
Re: Getting position from first keyframe only
on Dec 13, 2018 at 8:08:00 pm

Try this:

L = thisComp.layer("Motion Path A");
if (L.transform.position.numKeys > 1) {
L.transform.position.valueAtTime(L.transform.position.key(1).time);
} else {
L.transform.position;
}


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index


Mike Foran
Re: Getting position from first keyframe only
on Dec 13, 2018 at 8:24:09 pm

Bingo! That's the ticket. Thanks Walter.


Return to posts index

Richard Garabedain
Re: Getting position from first keyframe only
on Dec 13, 2018 at 7:29:56 pm

could you parent the light to a null and use stardusts starting keyframe to parent to the position of the null?


Return to posts index

Mike Foran
Re: Getting position from first keyframe only
on Dec 13, 2018 at 7:58:26 pm

could you parent the light to a null and use stardusts starting keyframe to parent to the position of the null?


Yes, but the issue here is that I am trying to adjust the path of the light that the particles are to follow (actually several of them) and if I move the first keyframe of the light position, the entire path of particles becomes offset from the path. The emitter position of Stardust needs to have the same coordinates as the first keyframe of the light path. So parenting the light to a null doesn't solve my issue in this case. Thank you though.


Return to posts index

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