FORUMS: list search recent posts

trying to run time mapped animation when null object position changes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Gregor Knell
trying to run time mapped animation when null object position changes
on May 7, 2013 at 5:02:46 pm

Hey all,
I have a 6 frame animation within a time remapped layer named "Blue" that I'm trying to run one time every time a null object changes position.

I have the time remap attached to a slider and I have the Null object keyframes set to "Hold" so the position only changes on a new keyframe.

With my weak knowledge of expressions and sliders, this is what I've come up with so far:

n1 = thisComp.layer("Null 1");
thisframe = n1.position.valueAtTime(time);
prevframe = n1.position.valueAtTime(time - thisComp.frameDuration);

if (thisframe != prevframe) {

[ go to frame 1 of "Blue" and run 6 frames ]

}


My two issue:
1.) I haven't been able to find how to tell "Blue" to go to frame 1 and run 6 frames and then stop. Is this a loopin expression?

2.) Despite both "thisframe" and "prevframe" displaying the correct values, my if statement does not work when tested.


Any tips or advice would be greatly appreciated!
Best,
G


Return to posts index


Dan Ebberts
Re: trying to run time mapped animation when null object position changes
on May 7, 2013 at 5:58:04 pm

If you just need your 6-frame sequence to run at each of Null 1's position keyframes, something like this should work:


p = thisComp.layer("Null 1").transform.position;
n = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
}
if (n > 0){
t = time - p.key(n).time;
Math.min(t,framesToTime(5))
}else{
framesToTime(5);
}



Dan



Return to posts index

Gregor Knell
Re: trying to run time mapped animation when null object position changes
on May 9, 2013 at 2:01:38 am

Dan,
Thanks so much for the help, that's exactly what I was looking for!
Now just to dissect it!

All the best,
Gregor


Return to posts index


Gregor Knell
Re: trying to run time mapped animation when null object position changes
on May 10, 2013 at 6:15:58 pm

Hey Dan,

I took your code and tried to take it a step further for what I'm looking to do but ran into an issue.

I'm trying to have a number of time remapped layers responding to multiple keyframes on the same null object. I've condensed 30 minutes of keyframes down into 5 minutes so there's a lot of keyframes between frames.

This gets a bit confusing but within each frame, I'd like to sequentially send the keyframes to the time remapped layers. I hope that makes sense? Seeing what I'm doing in the code might help more.

The code works sometimes but then, regardless of where I am in the composition, I get this warning: Bad method arguments: This property has no keyframe numbered 8072, expression disabled. Error occurred at line 13.

(the null object has 8071 keyframes)

I've marked the things that I've added to you code with what I think they do based on my tests.

Any advice or strategy on how to approach this would be greatly appreciated.
All the best,
Gregor

p = comp("12").layer("Null 1").transform.position;
n = 0

if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
}


d = comp("Bulk").layer(index).index; // Current Layer index number.
v = (n+d-1); // Next keyframe index number to effect.
c = p.nearestKey(time).time; // Time of current keyframe.
n = p.key(v).time; // Time of next keyframe.


if ((n-c) &lt; (1/23.976)){ // If the time between the current keyframe and the next one is less then 1 frame (1/23.976)...
t = time - p.key(v).time;
Math.min(t,framesToTime(5))
} else {
framesToTime(5);
}


Return to posts index


Dan Ebberts
Re: trying to run time mapped animation when null object position changes
on May 10, 2013 at 6:34:08 pm

It looks like v can exceed the number of keyframes. I'm not sure what you want to do in that case, but you could eliminate the error message by doing something like this:

v = Math.min((n+d-1),p.numKeys);


Dan



Return to posts index

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