How can I get physics to be independent of the current FPS?

Hi,

I’m making a ball rolling game where timing is essential and therefore the maximum ball speed must under all circumstances be equal on all systems, independent of the frame rate.

Now I’ve tried several methods of moving the ball (add force, add impulse, manually setting the linear and angular velocity, …) but always the ball’s speed depends on the current FPS. At the moment - and this is my best try - the ball speed is ~270 at 30fps, ~283 at 60fps and ~290 at 120fps. I’ve also played with physics substepping, without success.

Any tipps or ideas? Thanks!

1 Like

I would expect AddForce to work independent of the framerate, especially if you have sub-stepping on.

Would you be able to post a simple repro?

Okay, I’ll go back to my AddForce method and post the BP graph soon. Or do you need a complete sample project?

If your setup is simple enough the BP graph should be good enough.

awww, I think I found my error. I was multiplying the add force vector by the delta time because I always though I’d have to do this when dealing with movement. But I guess I should not do that when physics are involved, because they have their own delta?

Yes that is correct. When you apply a force you’re applying an acceleration over the duration of the frame. Under the hood the physics engine will account for the acceleration * delta time.

Thanks!

For documentation: don’t multiply the “Add Force” vector by delta time, because the physics engine will take care of that automatically.

If the frame time is varying, though, then this will apply a varying impulse based on frame rate.

Assuming the user wants constant acceleration, using Add Force without accounting for frame time is correct. If the frame took longer the underlying rate of change will be bigger, but this is the expected behavior.

Ok, I had the same problem. I mean I WAS NOT multiplying by Delta Time, but still, If I capped the game at 30fps the object was clearly pushed much harder with AddForce and even was ending up much further than when I was playing with uncapped (around 120fps) framerate.

Now that I think about it, my object has a little of linear and angular damping and it looks like these values, under the hood, are not taking Delta Time into accound.

I’m on 4.17.

1 Like

I have exactly the same problem. They are saying that it’s independent from the frame rate but it’s not true at all. Unfortunately this will prevent my entire idea from realization. It works perfectly on some fps, like 120 for example, and it’s completely different when fps is 60, 90 or in the worst case 30.

1 Like