Skip to content

Feat: Add camera vehicle view offset - #5260

Open
PrimelPrime wants to merge 2 commits into
multitheftauto:masterfrom
PrimelPrime:feat/camera-vehicle-view-offset
Open

Feat: Add camera vehicle view offset#5260
PrimelPrime wants to merge 2 commits into
multitheftauto:masterfrom
PrimelPrime:feat/camera-vehicle-view-offset

Conversation

@PrimelPrime

Copy link
Copy Markdown
Contributor

Summary

Adds three new clientside functions that let you offset the vehicle follow camera.
Each of the six view modes in eVehicleCamMode keeps its own offset once set.

bool setCameraVehicleViewOffset ( int viewMode [, float x, float y, float z] )
float, float, float getCameraVehicleViewOffset ( int viewMode )
bool resetCameraVehicleViewOffset ( [ int viewMode ] )
  • viewMode is 0-5 (eVehicleCamMode: BUMPER, CLOSE_EXTERNAL, MIDDLE_EXTERNAL, FAR_EXTERNAL, LOW_EXTERNAL, CINEMATIC).
  • Only the external chase views 1-4 can currently be offset.
  • Both BUMPER and CINEMATIC are processed by different CCam functions and never reach CCam::Process_FollowCar_SA where the offset is applied thus currently resulting in no-ops -> Returning false for them instead would also be an option.
  • The offset is in camera space -> x = right/left, y = towards/away from the vehicle, z = up/down, in game units, clamped to +-20.
  • resetCameraVehicleViewOffset() without an argument clears every view mode.
  • OOP: Camera.setVehicleViewOffset, Camera.getVehicleViewOffset, Camera.resetVehicleViewOffset.

Motivation

Currently trying to change the camera for the vehicle is only really possible by completely rebuilding it using setCameraMatrix on every frame. That loses SAs own camera behaviour and is a complex task by itself recreating said camera in Lua. To add to that trying to raise the camera for specific models on the z-axis is only possible by manipulating the model in certain ways (which may affect vehicle physics) but that way it can simply be handled via a simple single function call.

Test plan

  1. Default behaviour remains unchanged -> Cycle through the different view modes
  2. start runcode
  3. crun setCameraVehicleViewOffset(2, 0, 0, 2) on any view mode with any settings (max +-20) -> Cycle through again
  4. crun getCameraVehicleViewOffset(2) -> returns three floats: i.e. 0, 0, 2
  5. crun resetCameraVehicleViewOffset(2) -> Cycle through once again

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.

@ArranTuna ArranTuna added the enhancement New feature or request label Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants