Jump to content
Sign in to follow this  
swaino

Floor Bounce Expression - Help

Recommended Posts

Hi

 

Does anyone know how to delay the effects of this expression by a user defined number of seconds or frames? By default, it starts at the first frame of the comp. Sliding or splitting the layer doesn't help. Thanks!

 

- - - - - - -

 

Object bouncing on a floor

This will make your layer/object bounce along an imaginary 'floor'. Paste it into the 'position' attribute for your layer.

 

Vy0 = 500; //initial y velocity (pixels/second)

Vx0 = 100; // initial x velocity (pixels/second)

g = 2500; // gravity (pixels/second/second)

floor = 400;

e = .85; //elasticity

b = floor - position[1];

h = b + Vy0*Vy0/(2*g);

T = Vy0/g + Math.sqrt(2*h/g);

if (time < T){

y = Vy0*time - g*time*time/2 + b;

}else{

Vy = -(Vy0 - g*T);

while (true){

Vy *= e;

t = T;

T += 2*Vy/g;

if (time < T){

t = time - t;

y = Vy*t - g*t*t/2;

break;

}else if (T - t < thisComp.frameDuration){

y = 0;

break;

}

}

}

[position[0] + Vx0*time, floor - y]

Share this post


Link to post
Share on other sites

Hey Dave,

 

Try this:

 

 

Vy0 = 500; //initial y velocity (pixels/second)

Vx0 = 100; // initial x velocity (pixels/second)

g = 2500; // gravity (pixels/second/second)

floor = 400;

e = .85; //elasticity

b = floor - position[1];

h = b + Vy0*Vy0/(2*g);

T = Vy0/g + Math.sqrt(2*h/g);

 

offset = 2;

timeOffset = time - offset;

 

if (time > offset){

if (timeOffset < T){

y = Vy0*timeOffset - g*timeOffset*timeOffset/2 + b;

}else{

Vy = -(Vy0 - g*T);

while (true){

Vy *= e;

t = T;

T += 2*Vy/g;

if (timeOffset < T){

t = timeOffset - t;

y = Vy*t - g*t*t/2;

break;

} else if (T - t < thisComp.frameDuration){

y = 0;

break;

}

}

}

 

}

if (time > offset){

[position[0] + Vx0*timeOffset, floor - y]

} else {

transform.position;

}

 

 

 

I just made two new variables: offset and timeOffset

If you change offset, that will determine now many seconds it waits to start. timeOffset just replaces all the previous time properties to account for the offset variable so it calculates correctly.

 

R

Share this post


Link to post
Share on other sites

Hey Dave,

 

Try this:

 

...

 

I just made two new variables: offset and timeOffset

If you change offset, that will determine now many seconds it waits to start. timeOffset just replaces all the previous time properties to account for the offset variable so it calculates correctly.

 

R

 

I probably owed you a beer already...but I DEFINITELY owe you one now! Worked perfectly. Thanks!

Share this post


Link to post
Share on other sites

I probably owed you a beer already...but I DEFINITELY owe you one now! Worked perfectly. Thanks!

 

I'll have to take you up on that when we're both not so freakin' busy! :lol:

 

R

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...