Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Help with if / else statement

  • Help with if / else statement

    Posted by Stephen Reber on August 1, 2009 at 9:47 pm

    Ok, I’m just messing around with expressions and just testing some stuff, and am working on simulating gravity.

    Then I decided that when my object reached the bottom of the screen, it would go back to the top and stay there. This is what I have, but it doesn’t work.

    x = transform.position[0];
    y = transform.position[1]; // y is equal to ft or meters

    m = thisComp.layer(“Null 1”).effect(“mass”)(“Slider”);
    g = thisComp.layer(“Null 1”).effect(“gravity”)(“Slider”);

    yFall = y + m * g;

    if ( yFall >= thisComp.height)
    {
    yFall * 0
    } else {
    yFall
    };

    [x, yFall]

    I was messing with if/else statements earlier last week, but I have to be missing something.

    Thanks in advance…

    Stephen =]

    Filip Vandueren replied 17 years ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    August 2, 2009 at 1:09 am

    Are you animating the sliders ?

    The problem is that if you’re using the sliders to set fixed values, nothing changes from frame to frame, so there’s no movement.
    You need to factor in time to animate this.

    for example:

    yFall=y + (g/2)*(time*time);

    wich is the classic Newtonian equation for a falling body.
    Mass has nothing to do with theoretical falling, as you might remember from physics class. Or from the astronaut dropping a feather and a hammer on the moon (how did they fake THAT ? 😉 )

    You may however want to figure in air-resistance and terminal velocity which do factor in Mass.
    Let me know if that accurately a simulation is important, and we’ll try to solve it using the info at this url:

    https://en.wikipedia.org/wiki/Drag_(physics)#Velocity_of_a_falling_object

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