Skip to content

Fix fixed camera desync when the player's vehicle gets destroyed - #5285

Open
TheCrazy17 wants to merge 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/fixed-camera-anchor
Open

Fix fixed camera desync when the player's vehicle gets destroyed#5285
TheCrazy17 wants to merge 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/fixed-camera-anchor

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

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

  1. Enter a vehicle, set the camera far away with setCameraMatrix, then destroy the vehicle; the camera stays where the script put it and the world around it keeps its collision.
  2. Same but exiting the vehicle and restarting the resource instead.
  3. Regular camera work is unaffected: fixed camera while driving, moving it around, restoring with setCameraTarget, and changing the player's model with the camera fixed.

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.

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.
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.

setCameraMatrix/target bug Camera desync and collisionless world

1 participant