So I’m making a zombie shooter type game and I was wondering how I would go about making a top down camera similar to these!
Made my @Kennycell
Note: I am a dev in training and I can build but when it comes to scripting I can read and edit scripts to fit what I want them to do but I cant create scripts from scratch
To lock the camera you could set the CameraType property to Enum.CameraType.Scriptable
Then bind a function to the RenderStepped event of RunService that sets the camera’s CFrame.
If you wanted the camera to look down diagonally in an isometric style you could construct the CFrame like this:
local lookAt = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local camDistance = 20
workspace.CurrentCamera.CFrame = CFrame.new(lookAt) * CFrame.fromOrientation(math.rad(-45), math.rad(45), 0) * CFrame.new(0, 0, camDistance)
local rs = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local distance = 30
local cf = CFrame.fromOrientation(math.rad(-45), math.rad(45), 0) * CFrame.new(0, 0, distance)
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
rs:BindToRenderStep("camLock", Enum.RenderPriority.Camera.Value + 1, function()
if (player.Character and player.Character:FindFirstChild("HumanoidRootPart")) then
workspace.CurrentCamera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * cf
end
end)
As long as it is in any of those places where local scripts can run, although StarterPlayer.StarterPlayerScripts is the most appropriate place for it in my opinion.