Fix fixed camera desync when the player's vehicle gets destroyed - #5285
Open
TheCrazy17 wants to merge 1 commit into
Open
Fix fixed camera desync when the player's vehicle gets destroyed#5285TheCrazy17 wants to merge 1 commit into
TheCrazy17 wants to merge 1 commit into
Conversation
Entering fixed mode still calls GTA's TakeControl with a real entity to switch the native camera mode, and GTA keeps a tracked reference to it for as long as fixed mode lasts. Anchoring on the vehicle meant destroying it, or a resource restart cleaning it up, made GTA notice the dead reference and quietly point the camera back at the player, desyncing it from our fixed state and the world streaming around it. The player ped doesn't get destroyed from under us, so anchor on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Entering fixed camera mode calls GTA's TakeControl with a real entity to switch the native camera mode, and GTA keeps a tracked reference to it for as long as fixed mode lasts. CClientCamera preferred the local player's vehicle, so destroying it (or a resource restart cleaning it up) made GTA notice the dead reference and quietly point the camera back at the player; getCameraMatrix and the world streaming desynced from the native camera, which is where the collisionless world in the reports comes from.
Anchoring on the player ped removes the dangling reference; the ped doesn't get destroyed from under us, and for players on foot this was already the behavior.
Motivation
Fixes #544.
Fixes #1463.
Test plan
Checklist