Facepunch / sbox-issues

175 stars 12 forks source link

Rigidbodies don't interpolate properly at lower time scales #6448

Open youarereadingthis opened 1 month ago

youarereadingthis commented 1 month ago

Describe the bug

When you lower the time scale it seems to also slow down the physics update rate. This wouldn't necessarily be a problem if the interpolation worked properly at lower scene time scales, but it doesn't.

To Reproduce

  1. Enter/create a scene where you can add force/impulses to rigidbody physics objects.
  2. Lower the time scale to something like 0.3f or less.
  3. Apply enough force to the rigidbodies to have them moving, rotating, colliding.

Expected behavior

Rigidbodies should move smoothly at lower time scales.

Media/Files

https://github.com/user-attachments/assets/9ea7c7dd-ba14-4cc1-b08d-dcf892b2c742

Additional context

In the attached video I've lowered the time scale of the slow motion ability to 0.1f just for the sake of example.

I've gotten around this in the past by scaling the update rate relative to the time scale but that's a workaround, not a solution we should be required to implement for games utilizing SlowMo.

kurozael commented 1 month ago

Hey. would you be able to provide a repro project for this? It'll make it easier to track down because as you can see here in this video I'm not noticing the same thing.

https://github.com/user-attachments/assets/e49639e4-2ed8-4947-934e-1a02f92fe77d

youarereadingthis commented 1 month ago

Hey. would you be able to provide a repro project for this? It'll make it easier to track down because as you can see here in this video I'm not noticing the same thing.

It's happening to both of my projects that implement SlowMo, and all I'm doing is setting Scene.TimeScale in code. In my current project I don't even have a game manager so I'm definitely not doing anything fancy.

Could it be that setting Scene.TimeScale each update resets the interpolation?

I'll try getting around to making that repro.

kurozael commented 1 month ago

Thanks, a repro will help for sure, is it a networked game? If so TimeScale must match for all clients.