Activity › Forums › Adobe After Effects Expressions › Expressions stop functioning when key-framed
-
Expressions stop functioning when key-framed
Posted by Daniel Gies on May 21, 2010 at 8:41 pmI have a number of expressions controlling the “time remap” and position of nested layers inside an animated character. When I add key frames to the objects in the root composition that are driving some of my expressions they stop working completely. Has anyone ever encountered this before?
I can post some examples if it is needed. I thought what I was doing was pretty straight forward.
Thanks
dan
//The numbers are pulled from a parent composition and this code is applied to the time-remap property.sliderOrigPos = 150;
sliderPos =comp("Violet").layer("MouthTimeCntrl")("Transform")("Position")[0]
sliderDiff = sub(sliderPos,sliderOrigPos);sliderDiff/250;
Dan Ebberts replied 15 years, 12 months ago 2 Members · 7 Replies -
7 Replies
-
Dan Ebberts
May 21, 2010 at 10:43 pmI see a couple of things. First, why are you using the vector subtract function to subtract a couple of numbers that aren’t vectors? I’d think you want to use plain old subtract operator (-).
Second, you’re aware that the time remap property expects values in seconds, not frames, correct?
Dan
-
Daniel Gies
May 22, 2010 at 4:02 pmThank you Dan, I am going to start digging into this.
I am pretty new to expressions and started using vectors because someone more skilled than me had used them in a similar piece of code. So I thought they were the better way to do it.
What qualifies something as a vector?
As for the time re-map I wasn’t fully aware of that. Perhaps it will help.
Thanks for getting back to me so quickly. I figured I owuldnt hear a word for days and days.
dan
-
Dan Ebberts
May 22, 2010 at 4:32 pmYou would use vector math for values and properties that have multiple dimensions, like scale and position. But even then, there’s no longer any need to use the old operators like add() and sub(). For example, to calculate a point up 100 pixels and left 100 pixels you could do it the old way:
sub(position,[100,100])
or just:
position – [100,100]
Dan
-
Daniel Gies
May 22, 2010 at 5:11 pmInteresting. Well that is great to know.
I have been playing more with my problem and made some discoveries. I changed all the code as you suggested and removed all the java math operators.
What I had originally was, for example, A head composition made up of 6 frames and 8 layers. Each frame had a different head composition ie.front,3/4,side…each taking up there own layer. The top two layers had two eye compositions. The eye compositions consisted of an eye white, a pupil and an eyelid layer. The pupil was coded to follow a little square in the root composition.
What I was trying to do was control the timing of each composition through code. So if the slider was set to 3/4 view the head comp would be on frame three, while the eye comp would be on frame 6 and the mouth comp would be on frame 25.
It worked when I was on frame 1. I had a perfectly interactive little puppet controlled by sliders and everything. But once a single keyframe was applied, everything stopped working.
What I have found is that my head and eye compositions only work if they have as many frames as the main compositions. It seems that without frames to play in, the code doesn’t work….
I don’t know if this is making any sense.
Anyways, thanks for the help so far. It is too bad the code can’t function independent of time. If you have any thoughts on how this might be possible, or maybe I am missing the boat entirely, that would be great.
Thanks Dan
-
Dan Ebberts
May 22, 2010 at 5:36 pmIt’s hard to say without seeing your project, but it sounds like you’ve turned on time remapping for the precomp layers in your main comp, and have applied expressions to the time remap property, is that correct? Once you turn on time remapping for a precomp layer, you need to drag the duration out to match your main comp or nothing will show up when the main comp time gets past the outpoint of the precomp layer. I’m not sure if that’s your problem, but I can’t think of any reason why you shouldn’t be able to do what you’re trying to do.
Dan
-
Daniel Gies
May 22, 2010 at 5:41 pmWell I cant possibly explain what I was doing unless I sent you the project file. It just doesn’t work right the way I was doing it.
Thanks for all your help.
I have one last question. Is there a way to create an input text field that can pass a value from one comp to another? Basically I want to attach a text box to the characters head where the animator can type in a value that will tell the mouth comp what frame to be on.
It gets complicated because I would want it so that if they typed in 1 on frame whatever and then typed in 25 on frame whatever, it would interpolate from 1 to 25 sequentially.
Is that possible?
-
Dan Ebberts
May 22, 2010 at 5:56 pmIf you need it to be text, you could use marker comments and have your time remapping expressions pick those up, or if it’s just numbers, you could just keyframe a slider. In either case, you’d want your expression to retrieve the previous and next values so that it could interpolate between them. It’s not trivial, but it’s all very do-able.
Dan
Reply to this Discussion! Login or Sign Up