Floor Bounce Expression - Help
Started by swaino, May 17 2011 05:28 PM
3 replies to this topic
#1
Posted 17 May 2011 - 05:28 PM
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]
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]
#2
Posted 17 May 2011 - 07:54 PM
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
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
#3
Posted 18 May 2011 - 03:46 AM
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!
#4
Posted 18 May 2011 - 04:22 AM
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!
R
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users










