Skip to content

Fix conformPedRotation drift while ped is moving forwards#5015

Open
QueryOfficial wants to merge 1 commit into
multitheftauto:masterfrom
QueryOfficial:fix/ped-script-rotation-override
Open

Fix conformPedRotation drift while ped is moving forwards#5015
QueryOfficial wants to merge 1 commit into
multitheftauto:masterfrom
QueryOfficial:fix/ped-script-rotation-override

Conversation

@QueryOfficial

Copy link
Copy Markdown
Contributor

Summary

Re-apply script-set ped rotation after GTA movement tasks overwrite it each frame.

When setElementRotation / setPedRotation (or server SET_PED_ROTATION) sets ped rotation, the client now stores that value and restores it at the start of PostWorldProcessHandler, after ProcessPedsAfterPreRender, and before puresync/keysync writes. This keeps conformPedRotation=true stable while the ped is walking on foot and stops remote players from flickering between two rotations.

Motivation

Fixes #4694

GTA’s on-foot movement task adjusts ped heading every frame (e.g. ~5° drift while forwards is held). Script rotation set in onClientPreRender was overwritten before the next frame and before network sync, so getElementRotation showed a different value and remote clients saw alternating rotations.

This follows the same idea as frozen ped matrix re-apply: persist the script value and restore it after the engine has run.

Test plan

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

- Implemented `ReapplyScriptRotations` in `CClientPedManager` to update ped rotations when the game is loaded.
- Added `SetScriptRotationOverride` and `ReapplyScriptRotationIfNeeded` methods in `CClientPed` to manage script rotation states.
- Updated `CClientGame` to call `ReapplyScriptRotations` during post-world processing.
- Ensured script rotation overrides are cleared when a ped enters a vehicle.

This change enhances the accuracy of ped rotations in the game environment, addressing potential desynchronization issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Player rotation with conformPedRotation is not being persistent correctly when moving forwards

1 participant