-
Bal bouncing on floor
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]