Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bal bouncing on floor

  • Bal bouncing on floor

    Posted by Annebelle Van zweden on August 14, 2013 at 1:09 pm

    Hi,
    I’m learing expressions from a book, and in this book there is the next example:

    There are two elements; a ball and a floor (floor is a long small horizontal solid)
    The expression will make the ball bouncing on the floor. I have to start with the ball’s position resting on the floor.
    Then I have to add the follow expression on ball’s position;

    var bouncesPerSecond = 1.5;
    var bounceStrength = 200;
    var decayRate = .5;
    var floor = thisComp.layer(“floor”).transform.position[1];
    var bounceOffset = Math.abs(Math.cos(bouncesPerSecond * time * 2 * Math.PI));
    var y = bounceStrength * bounceOffset/Math.exp(decayRate * time);
    floor = floor - (height/2);
    [position[0], floor] - [0,y]

    I understand most parts of the expression, but I totally don’t understand all the ‘floor’ parts. What happens there exactly? And it also doesn’t work in my composition. The ball doesn’t hit the floor anymore, but bounces far above the floor.

    Why is the expression not like this (also starting with ball’s position on the floor)?:

    var bouncePerSecond = 1.5;
    var bounceStrength = 200;
    var decayRate = .5;
    var x = transform.position[0];
    var bounceOffset = Math.abs(Math.cos(bouncePerSecond * time * 2 * Math.PI));
    var y = transform.position[1] – (bounceStrength * bounceOffset/Math.exp(decayRate * time));
    [x,y]

    I hope somebody can explain me.
    Thanks in advance,

    Annebelle

    var bouncesPerSecond = 1.5;
    var bounceStrength = 200;
    var decayRate = .5;
    var floor = thisComp.layer("floor").transform.position[1];
    var bounceOffset = Math.abs(Math.cos(bouncesPerSecond * time * 2 * Math.PI));
    var y = bounceStrength * bounceOffset/Math.exp(decayRate * time);
    floor = floor - (height/2);
    [position[0], floor] - [0,y]

    Annebelle Van zweden replied 13 years ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    August 14, 2013 at 10:25 pm

    It depends where you set the anchor points of the two layers (ball and floor), and particularly of the ball. And the choice depends on what to do after (is the ball spinning, is it squizzed when hitting the ground ?) For spinning you would set the ball’s anchor at its center, for squizzing/stretching at its bottom. None of that is fine, bot is “hard”…

    In the expression from your book, apparently the floor’s anchor should be on its top edge, and the ball’s anchor at its center. Also to account for an eventual change of scale you should change height by height*scale[1]/100;

    There are plenty of bounce expressions on MotionScript: https://www.motionscript.com/articles/bounce-and-overshoot.html.

    Xavier.

  • Annebelle Van zweden

    August 15, 2013 at 8:17 am

    Hello Xavier,

    Thank you for the link.
    The anchorpoints are both in the middle of their element.
    But the expression in the book remains strange. It doesn’t work, and I also don’t understand what it does with the floor part.
    But, maybe I’ll let it go 😉
    I will take a look at the bounce expressions you gave me.
    Thanks!

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