Is Framerate Independency just impossible using RenderStepped?

Below is some code I wrote to simulate gravity for a fireball that ticks every frame. It has an initial upward velocity and then falls back down in an arc. The rate at which it falls is all multiplied by delta time so that it will not fall slower or faster based on the client’s framerate but will rather be consistent. I’ve verified on multiple sites this is the correct formula for consistent acceleration.

fireBall.Position = (fireBall.Position + vel * DT + Vector3.new(0,GRAV,0) * DT * DT)
			vel = vel - Vector3.new(0,GRAV,0) * DT

However at lower framerates like 5 - 20 it will land further and further away. Below is a picture of where the attack lands at 60 fps and 5.

Screenshot 2024-03-01 150041

I know game physics tied to framerate is a problem even for triple-A games like DOOM or FALLOUT but this disparity is very noticeable and not good for projectile attacks. Is there any way to make it more consistent? Or is it just an unfixable quirk of the engine?

1 Like
fireBall.Position += (vel * DT) + (Vector3.yAxis * GRAV * DT)
vel -= Vector3.yAxis * GRAV * DT
1 Like
fireBall.Position += (vel * DT) + (Vector3.yAxis * GRAV*0.3 * DT)
			vel -= Vector3.yAxis * GRAV * DT

I modified a bit so it wouldn’t fly upwards at 1million miles per hour but upon testing it does seem to be more accurate, not exact but more.

Screenshot 2024-03-01 152824

Any idea as to why this is?
I always thought since it is the rate of deceleration it must be multiplied by dt twice, such as

position += velocity * timeStep + 0.5 * acceleration * timeStep * timeStep;
velocity += acceleration * timeStep;
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.