Seated rear view camera offset

  1. What do you want to achieve? While seated offset the camera left or right when looking back.

  2. What is the issue? The game will be in first person only and right now, when you are trying to reverse a vehicle you cant see anything, seat just blocks the view.

I tried raycasting but yeah, realized its not an option because every time it casts a ray at a seat it keeps hitting and missing so the camera goes crazy :frowning:

local player = game.Players.LocalPlayer
local char = player.Character
local RunService = game:GetService("RunService")

	local ray =, workspace.CurrentCamera.CFrame.LookVector*2)
	local ignoreList = char:GetChildren()
	local hit, pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
	if hit then
		char.Humanoid.CameraOffset =, 0, 0)
		char.Humanoid.CameraOffset =, 0, 0)

I would recommend a custom camera script for this, but I’ve made this and it works. This won’t work correctly in third person, but you said the game is first person only. This uses the dot product of the camera look and character look vectors. Basically, how close are the two vectors to each other (from -1 to 1).

Here is the code:

local runService = game:GetService("RunService")
local finalOffset =, 0, 0)

local cam = workspace.CurrentCamera
local primaryPart = script.Parent:WaitForChild("HumanoidRootPart")
local humanoid = script.Parent:WaitForChild("Humanoid")

	humanoid.CameraOffset = finalOffset * math.min(0, cam.CFrame.LookVector:Dot(primaryPart.CFrame.LookVector))

This absolutely gets the job done! I’ll still fiddle around with it and see if I can get it to lean on the other side too, but Thank you so much for helping me out and sharing this gem!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.