FORUMS: list search recent posts

how do i play comp on keyframes

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mikkel Sørensen
how do i play comp on keyframes
on Dec 12, 2015 at 4:49:11 pm

Hello My name is Mikkel.
I'm brand new and this is my first post so be gentle :D

I'm in the process of teaching myself some stuff in after effects and i hit a wall.
In this process I have been doing music videos and i have gotten far just by watching YouTube tutorials.
With trapcode sound keys i have been able to do some awesome stuff like keying particle effects to the bass of a song and stuff like that.

What i want to do now is play a simple animation when keyframes generated by sound keys hits 1.
It should play the animation every time the slider hits 1 even though an instance of the animation is already running.
For now i managed to make a checkbox Controller turn on when the slider hits 1 and turn off when the slider goes below 1.

I would imagine that the checkbox should turn off immediately after it gets turned on otherwise the animation will get started every frame until the slider gets below 1 again...
I do have some experience coding c and c++ but how After effects scripting works is beyond me right now.
My guese as to how the code to run the animation should look is something like this.

if(lastSliderState != 1 && thisSliderState ==1){
//start new instance of the animation here
}
lastSliderState = thisSliderState;


but i have no idea as to how i set local variables and get the state of the slider...



Once this is done i would need to play that animation... this i have no idea how to do either or if it's even possible.
I could just stack the animation and fit it to the keyframes manually but i would have to duplicate and stack the animation over 100 times.

I might even be taking a completely wrong approach to this so any comment's on how you guys would solve this problem are welcome.

Thank you for reading this way to long post :)


Return to posts index

Walter Soyka
Re: how do i play comp on keyframes
on Dec 14, 2015 at 3:24:48 am

After Effects expressions are not executed like a program looping over frames. They have no idea of sequence. After Effects expressions are stateless. They are executed anew each time a frame is rendered. They have no "memory" of the frame before.

So you cannot simply trigger the start of an animation when a threshold is crossed. Rather, your expression must contain all the logic for the entire timing of the the animation relative to the threshold crossing.

Here's a post where I propose a solution to a problem similar to yours:
https://forums.creativecow.net/thread/2/1051293#1051428

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

Mikkel Sørensen
Re: how do i play comp on keyframes
on Dec 14, 2015 at 1:47:45 pm

looks promising. thanks.
It's vary nice knowing the code gets triggered each frame like a separate program with no knowledge of the code triggered last frame.

based on this and the code you provided i believe i can start working on a solution.

I'm gonna see if i somehow can re-trigger the animation by manipulating the echo effect's time and and number values.


Return to posts index


Walter Soyka
Re: how do i play comp on keyframes
on Dec 14, 2015 at 1:51:35 pm

[Mikkel Sørensen] "I'm gonna see if i somehow can re-trigger the animation by manipulating the echo effect's time and and number values."

Time remapping will render faster. I'd stay away from Echo unless you need to blend previous frames together.

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

Mikkel Sørensen
Re: how do i play comp on keyframes
on Dec 15, 2015 at 3:59:51 pm

I see what you mean. I tried manipulating the Echo effect and the render speed just dropped like lead in water.
Is it possible to play more than one frame from the same animation at the same time using Time-stretching and time-remapping?

example. I have an animation of a walking person.
This person is moved from the left of the screen to the right.
Now i want a new instance of that person to walk across the screen or maybe even 5 or 10.


Return to posts index

Mikkel Sørensen
Re: how do i play comp on keyframes
on Dec 15, 2015 at 4:16:55 pm

Might as well share some of the code i created to manipulate the echo time. If someone else find it useful :)

Bare in mind this code is rather crude.
I don't like while loops with nested while loops as they easily brake.
But this was the only solution i could come up with.

Would be nice if after effects had a global register where you could save information for use in later frames :)


// pointer to the state of the keymap
state = thisComp.layer("keys").effect("Sound Keys")("Output 2");

// The frame we are currently working with
frame = Math.round(time / thisComp.frameDuration);

// This while loop moves back one frame at a time.
// it's looking for the last time the state of the keymap reached 1
while(true){
t = frame * thisComp.frameDuration;
thisframe = state.valueAtTime(t);
prevframe = state.valueAtTime(t - thisComp.frameDuration);
if(thisframe == 1 && prevframe != 1){ //
timeatframe = t;
// The last time the keymap reached 1 has been found
// Now this while loop goes forward one frame at a time.
// when it find's the next time the keymap reaches 1 it can then calculate the time between those two points
while(true){
t = frame * thisComp.frameDuration;
thisframe = state.valueAtTime(t);
nextframe = state.valueAtTime(t + thisComp.frameDuration);
if(nextframe == 1 && thisframe != 1){
result = (t - timeatframe) *(-1);
break;
}

if(frame == Math.round(thisComp.duration / thisComp.frameDuration)){
break;
}
frame++;
}
break;
}
if (frame == 0){
break;
}
frame--;
}


Return to posts index

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