Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make a top-down camera but the player can't move it?

Asked by 1 year ago

I'm making a game where the camera is set to be top-down, I've made the script to make it top-down but I don't want the player to move it when walking. Any idea on how to fix this?

[local RunService = game:GetService("RunService")   

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

local CAMERA_OFFSET = Vector3.new(-1,90,0)

camera.CameraType = Enum.CameraType.Scriptable

local function onRenderStep()
    if player.Character then
        local playerPosition = player.Character.HumanoidRootPart.Position
        local cameraPosition = playerPosition + CAMERA_OFFSET

        camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
    end
end

RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
1 year ago

Then don't update the camera at all

local RunService = game:GetService("RunService")   

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

local CAMERA_OFFSET = Vector3.new(-1,90,0)

task.wait()
camera.CameraType = Enum.CameraType.Scriptable

if player.Character then
    local playerPosition = player.Character.HumanoidRootPart.Position
    local cameraPosition = playerPosition + CAMERA_OFFSET

    camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end
Ad

Answer this question