Fix #2939: Make ped pushing vehicle physics FPS independent - #5199
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
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 |
|
Something is still wrong. At 74 FPS, the vehicle now feels significantly heavier than it normally does. 74 FPS without your PR 74 FPS with your PR |
|
Yes, as I mentioned, I adjusted the car’s movement to match the original 30 FPS behavior. So players at 74 FPS may feel like it’s slower, but it’s actually just behaving the same as it does at 30 FPS, keeping things consistent across all frame rates. |
|
@FileEX The unrelated changes you mentioned are fixes for crashes that actually occurred because of the changes in this PR while testing, mainly vehicles crashing when repeatedly spawned or deleted during tests, and a crash if a vehicle gets destroyed during the collision event. That's why I bundled them together here, but if you still prefer to keep this PR focused on the ped push physics and move those into a separate PR, I have no problem doing that at all |
I admit that I don't quite understand how you're running into these issues/crashes, since your PR doesn't use any of these functions, such as If this were an issue with |
|
Yeah, it seems I didn't explain the crash fixes clearly enough. Basically, while testing the physics at high FPS, I also fixed an issue where spawned vehicles were going to sleep instantly on frame 1 with their suspension stretched up, so I prevented that premature sleep so they could settle naturally. But keeping them awake during those first spawn frames caused GTA to run things like UpdateClumpAlpha and matrix updates before the clump was even initialized, which immediately crashed the game at 0x732B2A and 0x59AD76. So I just added those hooks as shields to prevent those crashes from happening. But if you prefer to keep this PR strictly about the ped push physics and move the spawn-sleep fix and its crash hooks to a separate PR, I can easily split them. |
…nsion fixes Isolate ped push vehicle physics (multitheftauto#2939) into this PR. Remove vehicle suspension premature sleep fixes and crash defense hooks to be submitted in a separate dedicated pull request.
|
Here it's : #5429 |
|
Well, I'm not sure whether changing the behavior of vehicles even at 60 FPS, which everyone has been used to for years, is a good idea, but okay. Worst case, if people complain about it, we can revert it or find another solution. |
Closes #2939
Summary of Changes
Running into unoccupied vehicles at high framerates causes them to accelerate and slide unnaturally fast due to frequent collision impulses overpowering tire friction.
This PR governs pedestrian push impulses by:
Testing
https://streamable.com/3puhud