Fix #2939: Make ped pushing vehicle physics FPS independent - #5199
Fix #2939: Make ped pushing vehicle physics FPS independent#5199MohabCodeX wants to merge 6 commits into
Conversation
|
I feel like it's significantly harder to push the vehicle at 100 FPS. Why does it behave like that? |
|
Scaling the impulse by We could tweak it with something like 2026-08-17.08-42-20.1.mp4 |
|
It looks much better now |
|
Tested and it generally works, but it introduces a noticeable side effect, even at normal FPS. With your PR, the vehicle behaves strangely - it seems to bounce and lock its wheels, making it harder to move. 74 FPS without your PR (smooth) 74 FPS with your PR (rough, vehicle bounces) |
|
Quick update: After further investigation into the vehicle physics, I found that the previous implementation simply scaled raw collision impulses after impact, which didn't account for directional force distribution or tire physics. The new approach isolates horizontal rolling velocity from the vertical and tilt axes, governs forward acceleration and top speed using momentum conservation, and dynamically scales the vehicle sleep threshold with delta time so suspension settling stays consistent across framerates. I'll attach a video later Vehicle push behavior is now standardized to the 30 FPS baseline across all framerates. GTA:SA physics were tuned for 30 FPS,.. this prevents high-FPS collision impulses from breaking tire friction and causing vehicles to glide. |
84cf074 to
bb4481e
Compare
| constexpr float kOriginalTimeStep = 50.0f / 30.0f; | ||
|
|
||
| // Fixes player movement issue while aiming and walking on high FPS. | ||
| // Only rescales the compare threshold; m_MoveCmd's reset is NOPed separately in InitHooks_FrameRateFixes. |
| // Fixes camera jitter while aiming and walking at high FPS. | ||
| // CTaskSimpleUseGun::SetMoveAnim | ||
| MemSet((void*)0x61E5E4, 0x90, 0x6); |
There was a problem hiding this comment.
Accidental deletion during rebase .. restored now
bb4481e to
b150d7b
Compare
… at high FPS Spawned unoccupied vehicles at high framerates (e.g. 240 FPS) were going to sleep with their suspension fully extended/stretched, only settling to normal ride height when bumped by a player. This was caused by two issues in GTA:SA vehicle control: 1. The isVehicleIdle flag (0x6B1AF5 in CAutomobile, 0x6B9850 in CBike) forced instant sleep on frame 1 before gravity could settle the chassis. 2. Stationary parking damping in CAutomobile (0x6B361C) and CBike (0x6BC18F) wiped moveSpeed.z to 0 whenever speed was below 0.0045f. At 240 FPS, one frame of gravity is only 0.00166f (< 0.0045f), so vertical speed was erased on every single frame, preventing the springs from ever compressing. Changes: - NOP'd the isVehicleIdle instant-sleep flag in CAutomobile and CBike. - NOP'd moveSpeed.z zeroing in stationary damping so parking brakes only affect horizontal movement and yaw. - Scaled the 0.0045f stillness threshold by (timeStep / kOriginalTimeStep) across all comparison sites to maintain consistent sensitivity. - Scaled the sleep frame threshold by (kOriginalTimeStep / timeStep) to keep an invariant ~333 ms stillness window. Tested at 240 FPS with newly spawned vehicles; suspension now compresses and settles to normal ride height immediately on spawn without player touch.
|
Please resolve conflicts |
…cle-high-fps # Conflicts: # Client/multiplayer_sa/CMultiplayerSA_FrameRateFixes.cpp
|
While testing across framerates, noticed vehicles spawned at high FPS (100–240) were freezing with stretched suspension because the game was putting them to sleep on frame 1 before gravity could settle the chassis onto the springs. Disabled the instant-sleep bypass and stopped stationary damping from wiping small vertical gravity steps. Cars and bikes now settle naturally to their proper resting ride height across all framerates before going to sleep. Full Testing : https://streamable.com/3puhud |
Fix #2939: Make ped pushing vehicle physics FPS independent
Summary
Fixes an issue where running into vehicles at high FPS causes them to move and slide much faster and easier than at 30 FPS.
Solution
Scaled the vehicle's collision velocity delta by
timeStepRatiowhen pushed by a ped. This keeps the total impulse per second consistent across all framerates and matches the original single-player physics behavior.Notes & Considerations
Caution
While 100% mathematical parity across all framerates is practically constrained by the underlying GTA physics engine (Euler integration and discrete tire friction steps), this solution represents the closest and most balanced approach without rewriting the physics loop from scratch. Further reviews and community testing are welcome to ensure comprehensive coverage across edge cases.
Testing
Tested by pushing vehicles at 30 FPS vs 100 FPS.
2026-08-17.08-53-28.1.mp4