### Start time for gravity expression

Posted:

**April 2nd, 2021, 6:00 am**Hello everyone,

i want to use the gravity script from Dan Ebberts. It works perfect for me but i have no solution how i can integrate a start time via a time variable or a marker like: if (marker.numKeys > 0 && marker.key(1).time < time){

Here is the original script:

Code: Select all

```
Vy0 = 0; //initial y velocity (pixels/second)
Vx0 = 0; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 1000;
e = .82; //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 have a solution?

Many thanks for your help!