Hello, i edited this free isometric camera script in the toolbox, but i dont know what angles i need to use so it becomes a top down camera.
if anyone knows how to fix this it would be greatly appreciated.
heres the script.
local zoom = 50
local minZoom = 6
local maxZoom = 45
local FieldOfView = 70
local toggleEnabled = true
--// Do not edit unless you know what you're doing //--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Custom
-- Toggle functionality with "B" key
Mouse.KeyDown:Connect(function(key)
if key:lower() == "b" then
toggleEnabled = not toggleEnabled
end
end)
Mouse.WheelForward:Connect(function()
if toggleEnabled then
zoom = math.clamp(zoom - 3.5, minZoom, maxZoom)
end
end)
Mouse.WheelBackward:Connect(function()
if toggleEnabled then
zoom = math.clamp(zoom + 3.5, minZoom, maxZoom)
end
end)
-- Update the camera properties on every frame
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
if toggleEnabled then
Camera.FieldOfView = FieldOfView
if Character and Character:FindFirstChild("Head") then
game:GetService("SoundService"):SetListener(Enum.ListenerType.ObjectCFrame, Character.Head)
Camera.CFrame = CFrame.new(
Vector3.new(
Character.Head.Position.X + zoom,
Character.Head.Position.Y + zoom,
Character.Head.Position.Z + zoom
),
Character.Head.Position
)
end
end
end)
-- top of script
local zoom = 50
local cameraOffset = Vector3.new(0, zoom, 0)
-- in render stepped connection
Camera.CFrame = CFrame.new(Character.Head.Position + cameraOffset, Character.Head.Position)
The way the original script was setting the camera CFrame was verbose and less easy to modify the direction of the camera offset.
You can also specify which direction the camera should be orientated when looking down by using CFrame.lookAt:
-- top of script
local zoom = 50
local cameraOffset = Vector3.new(0, zoom, 0)
local cameraUpVector = Vector3.xAxis -- this will make the top of the camera align with the x-axis when the front of the camera is pointing down
-- in render stepped connection
Camera.CFrame = CFrame.lookAt(Character.Head.Position + cameraOffset, Character.Head.Position, cameraUpVector.Unit)
These can seem tricky. You have to deal with the camera overlapping the player’s HumanoidRootPart, as this can trigger fall damage when you zoom in. So either avoid zooming in or handle the overlap. This script does the latter.
--LocalScript in StarterPlayerScripts
local zoom = 50
local minZoom = 10
local maxZoom = 45
local FieldOfView = 70
local toggleEnabled = true
local smoothSpeed = 0.15
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Mouse.KeyDown:Connect(function(key)
if key:lower() == "b" then
toggleEnabled = not toggleEnabled
end
end)
Mouse.WheelForward:Connect(function()
if toggleEnabled then
zoom = math.clamp(zoom - 3.5, minZoom, maxZoom)
end
end)
Mouse.WheelBackward:Connect(function()
if toggleEnabled then
zoom = math.clamp(zoom + 3.5, minZoom, maxZoom)
end
end)
local RunService = game:GetService("RunService")
local currentCFrame = Camera.CFrame
RunService.RenderStepped:Connect(function()
if toggleEnabled and Character and Character:FindFirstChild("HumanoidRootPart") then
local hrp = Character.HumanoidRootPart
Camera.FieldOfView = FieldOfView
local targetCFrame = CFrame.new(hrp.Position + Vector3.new(0, zoom, 0), hrp.Position)
currentCFrame = currentCFrame:Lerp(targetCFrame, smoothSpeed)
Camera.CFrame = currentCFrame
end
end)