Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Seting the inital state of a variable (Fuse)

  • Seting the inital state of a variable (Fuse)

    Posted by Jesse Lucas on September 22, 2009 at 12:35 pm

    Hello,

    Its not the first time I come across this problem. But I usually find workarounds. Here it goes :

    I’m creating a “fuse” variable with 2 states which switch randomly.
    Basicly in state 0 a light’s intensity is a fixed value and in state 1 the intensity is controlled by a noise value.
    BUT, I can’t find a way to set the initial state of the fuse. I tried this :
    if (time == 0) fuse = 0…….
    But that doesn’t seem to work.
    Is there a way to set a variable only at run time of the script ?
    Thank you very much
    Jess

    Jesse Lucas replied 16 years, 11 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 22, 2009 at 8:15 pm

    It’s not clear what you’re trying to do, exactly, but it looks like you want set a variable at the first frame and have that value persist. Expessions can’t pass information from one frame to the next, so whatever you do at time = 0 is lost at the next frame. As you mention, there are usually ways around this, depending on what you’re trying to do.

    Dan

  • Jesse Lucas

    September 23, 2009 at 9:27 am

    Ok I’ll try and explain my problem again.

    I’m using a 3D light and I want it to randomly blink (like a broken neon).

    So I need the light to have 2 states :
    – Normal state, the light stays on
    – Blink state, the light blinks randomly

    In the code provided the “fuse” variable sets the state of the light. But I just can’t find a way to create the variable at code runtime.

    Any clue ?

    if (time == 0) {
    fuse = 0;
    }

    level = 270;
    amp = 100;
    if (random() > 0.9 && fuse ==0) {
    fuse = 1;
    }

    if (random() > 0.5 && fuse ==1) {
    fuse = 0;
    }

    if (fuse == 1) {
    noise(time*10) * amp + level-amp;
    } else {
    level;
    }

  • Dan Ebberts

    September 23, 2009 at 3:41 pm

    I think the path you’re on here will lead to nothing but frustration. See if this helps:

    https://www.motionscript.com/expressions-lab-ae65/swinging-light.html

    Dan

  • Jesse Lucas

    September 23, 2009 at 4:01 pm

    Thank you very much Dan. It looks like a nice solution.
    Too bad I didn’t just check your site before I posted.
    By the way, its nice of you to share all this valuable information.
    Have a nice day !
    Jess

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy