Hello, I’m making a side-view game and I want the type of camera that will follow the player but can’t be rotated, what would be the most straightforward way of doing this?
Nvm, I figured it out
const Players = game:GetService("Players")
const RunService = game:GetService("RunService")
const player = Players.LocalPlayer
local camera = workspace.CurrentCamera
const cameraSettings = {
zoom = 20,
height = 2,
fov = 60
}
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = cameraSettings.fov
local function UpdateCamera()
local character = player.Character
if not character then return end
local rootPart = character:FindFirstChild("HumanoidRootPart")
if not rootPart then return end
local cameraPos = rootPart.Position + Vector3.new(0, cameraSettings.height, cameraSettings.zoom)
camera.CFrame = CFrame.new(cameraPos)
end
RunService:BindToRenderStep("main_camera", Enum.RenderPriority.Camera.Value, UpdateCamera)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.