Modifying a 3rd Person Camera

Hi, I currently have a fully functional third-person shooter script, which works extremely well. But, its not at all what I set out for. In this camera, it locks the character’s movement to the mouse making the character move in the camera’s local direction. Gif below:
https://gyazo.com/48792e6b8aed6f925f5f0da8c700efe8

Is there a way I could modify this script so the character moves independently to the mouse so that the player could walk in different directions facing in those directions and the direction of the camera would only move when the mouse is moved. If anyone could give me some help it would be greatly appreciated. Heres the code:
local player = game:GetService(“Players”).LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")

local PlayerModule = game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")

local cameras = require(PlayerModule):GetCameras()

local CameraController = cameras.activeCameraController

local RunService = game:GetService("RunService")

toggle = true

game.ReplicatedStorage.cameraEnable.OnClientEvent:Connect(function()

CameraController:SetIsMouseLocked(true)

CameraController:SetMouseLockOffset(Vector3.new(1.75, 0, 0))

humanoid.CameraOffset = Vector3.new(1,0.5,0)

player.CameraMaxZoomDistance = 5

player.CameraMinZoomDistance = 5

end)
2 Likes

Unfortunately, you’re going to have to write an entirely new (and much longer) script. This script is basically cheating by using the MouseLock feature built in to Roblox. There is no way to modify the behavior to make the camera rotate independently using this method.

1 Like

Do you know how I could do to create this new script?

It’s complex, so I won’t detail the full thing here. The main idea is this though:

  • Get mouse delta (change in position) from UserInputService
  • Create a function to update the camera position on every frame based on that delta
  • Raycast from the player’s head to the desired camera position to make sure you dont hit any intersecting objects, and adjust accordingly

Seems simple, but it’s an art to make it look good. Hope that helps.