dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.28k stars 259 forks source link

Example of interpolated physics #422

Open jf908 opened 1 year ago

jf908 commented 1 year ago

I would expect that using a fixed physics tick rate with interpolated positions would be the default setup for most 3D games. It's the norm from other 3D game engines because tying physics to frame rate can make movement significantly inconsistent depending on how fast the game is running and without interpolation, movement won't look smooth when the game's framerate exceeds the physics tick rate.

I see that TimestepMode::Interpolated along with TransformInterpolation exist but I cannot get these to work because I'm not sure which schedules need to be setup. It also seems that TransformInterpolation is specific to RigidBody and wouldn't work with a KinematicCharacterController.

I think that having a minimal 3D example which demonstrates a KinematicCharacterController and a Rigidbody that simulate at a fixed tick rate but with interpolated positions would be extremely useful because I suspect that its the most prominent use case for using this library when making a 3D game. This all applies to 2D as well but it seems more common for 2D games to run at a fixed framerate. bevy-rapier has generally been a joy to learn and work with but this point has been particularly puzzling me.

jonastar commented 7 months ago

I also ran into this when I tried to switch to FixedUpdate to make my physics more consistent across systems and platforms but there doesn't seem to be a way to do this properly as of writing.

Right now I've accepted this limitation for now by linking my camera updates to FixedUpdate so I at least have something, but it's still pretty jank and jittery, especially on web builds.

There seems to be a pr addressing this unless I'm mistaken (https://github.com/dimforge/bevy_rapier/pull/474) but it's gone relatively stale.