Custom camera help

I’m looking into making a camera but i’m quite clueless as to how, even after youtube searching and scrolling through various devforums, I haven’t found anything close to what I’m after.

What I’m looking for essentially is a camera like the shift-lock camera (shoulder-surfing), except at a fixed distance (no zoom features, as i want to tween the camera back once the player starts sprinting, and back to the original position when walking) but rotating the camera does not affect the characters rotation, i.e it rotates/orbits around the player.

Any ideas?

1 Like
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local CAMERA_DEPTH = 24 -- Adjust this value to set the fixed distance
local HEIGHT_OFFSET = 2

local function updateCamera()
    local character = player.Character
    if character then
        local root = character:FindFirstChild("HumanoidRootPart")
        if root then
            local rootPosition = root.Position + Vector3.new(0, HEIGHT_OFFSET, 0)
            local cameraPosition = Vector3.new(rootPosition.X, rootPosition.Y, CAMERA_DEPTH)
            camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
        end
    end
end

RunService:BindToRenderStep("CustomCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)
1 Like

This is for a 2D game unfortunately, the camera I’m after is similar to games like warframe, nier, dmc etc.

1 Like

So I got a little closer to what I was after with a very simple script, however it’s not exactly accurate. The position of the camera and the movement is what I’m after, however due to how the camera offset works in the humanoid, the camera rotates relative to itself, I would like it to rotate around the player almost using it as an anchor point if that makes sense.

The script I mentioned is this:

local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

local function updateCamera()
	local character = player.Character
	if character then
		UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
		character.Humanoid.CameraOffset = Vector3.new(3, 0, -2)
	end
end

RunService:BindToRenderStep("CustomCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)