Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Expression to change value of keyframe

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Noel PowellExpression to change value of keyframe
by on Jun 4, 2012 at 2:20:36 pm

Hi. I'm looking for a way to use a slider control to change a parameter value at a specific keyframe. Or, if I can do it without keyframes, just a way to use a slider control to change the value at a specific frame.

Here is what I'm trying to do...
I need a slider control to change the number of particles using CC Particle World or CC Particle Systems II. The catch is the particles need to be static, so no new particles are formed. The only way I've found to stop new particles from forming is to have two keyframes on the "Birth Rate". The value at the first keyframe determines the number of particles, then on the next frame would be a keyframe with the value set to zero, stopping any new particles from forming. And then I would set the longevity to a high number so they don't disappear.
The other problem I will have to solve is having those particles visible immediately (starting at frame 1). This seems impossible to me though because the CC Particle Systems appears to need at least a few frames before any particles can be formed. And if I have an expression that points to a specific frame, and I slider the layer to the left so that the specific frame is before the 0:00 frame, then the time of that frame will have changed, screwing up the expression. I hope that makes sense. Thank you.


Return to posts index
Reply   Like  

Dan EbbertsRe: Expression to change value of keyframe
by on Jun 5, 2012 at 2:46:52 pm

I don't know if this helps, but this Birth Rate expression should give you a burst of particles at each layer marker:


burst = 10;

n = 0;
m = marker;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n > 0 && Math.abs((m.key(n).time - time)/thisComp.frameDuration) < .5)
burst
else
0


Dan



Return to posts index
Reply   Like  

Dan EbbertsRe: Expression to change value of keyframe
by on Jun 5, 2012 at 4:12:18 pm

This version might be closer to what you're after. It fires a burst of particles at each slider keyframe and gets the birth rate value from the slider at the keyframe.


p = effect("Slider Control")("Slider");

n = 0;
if (p.numKeys > 0){
n = p.nearestKey(time).index;
if (p.key(n).time > time) n--;
}
if (n > 0 && Math.abs((p.key(n).time - time)/thisComp.frameDuration) < .25)
p.valueAtTime(p.key(n).time+.01)
else
0


Dan



Return to posts index
Reply   Like  


Noel PowellRe: Expression to change value of keyframe
by on Jun 6, 2012 at 2:17:05 am

This is a life-saver. I don't fully understand it, but I'm just thrilled that it works. I couldn't use the first expression which used markers because it didn't allow the number of particles to be changed with the slider. The second one works great with one little addition. If the slider value was changed it would create new keyframes at that location, making the number of particles change. I needed the number to be constant, so I made that control slider a dummy slider with just one keyframe at the beginning, and created a new slider to control the number of particles. The dummy slider, which your birth rate expression still points to, now has this expression on it:

expression (effect("New Slider")("Slider")

Seems to do the trick. Thanks for your help, Dan


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]