Hi everyone, I’m trying to create a somewhat 3D game with an isometric camera—something that’s been done countless times in Roblox. However, I’ve never found the perfect camera setup. Currently, my system works pretty well, except for one issue. I’ve implemented a zoom in/out feature, since my goal is to make a board game where you need to see from a distance. But what I’ve noticed is that the more I zoom out, the less the camera looks like an isometric one. Could someone help me with this?
local Camera = game.Workspace.CurrentCamera
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local FOV = 20
Camera.CameraType = Enum.CameraType.Scriptable
Camera.FieldOfView = FOV
local isDragging = false
local DragStart = nil
local CameraPositionReference = Instance.new("Part", workspace)
CameraPositionReference.Size = Vector3.new(1,1,1)
CameraPositionReference.Anchored = true
CameraPositionReference.CanCollide = false
CameraPositionReference.Transparency = 1
CameraPositionReference.Position = Vector3.new(20,20,20)
CameraPositionReference.Orientation = Vector3.new(0, -40, 0)
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton2 or Input.UserInputType == Enum.UserInputType.Touch then
isDragging = true
DragStart = Input.Position
end
end)
UserInputService.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton2 or Input.UserInputType == Enum.UserInputType.Touch then
isDragging = false
end
end)
UserInputService.InputChanged:Connect(function(Input)
if isDragging == true and Input.UserInputType == Enum.UserInputType.MouseMovement or Input.UserInputType == Enum.UserInputType.Touch then
local DragDelta = Input.Position - DragStart
local DragDeltaWRLD = Vector3.new(DragDelta.X, 0, DragDelta.Y) * 0.1
local RightVector = -CameraPositionReference.CFrame.LookVector
local ForwardVector = -CameraPositionReference.CFrame.RightVector
local MoveVector = (RightVector * DragDeltaWRLD.X) + (ForwardVector * DragDeltaWRLD.Z)
CameraPositionReference.Position = CameraPositionReference.Position + MoveVector
DragStart = Input.Position
end
end)
RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(CameraPositionReference.Position + Vector3.new(20,20,20), CameraPositionReference.Position)
end)
UserInputService = game:GetService("UserInputService")
RunService = game:GetService("RunService")
local scrollSpeed = 3
local easeSpeed = 1
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel then
local up = input.Position.Z > 0 and 1 or -1
FOV += up * scrollSpeed
end
end)
RunService.Heartbeat:Connect(function()
local camera = workspace:FindFirstChild("Camera")
local fovCamera = camera.FieldOfView
local fovDifference = FOV - fovCamera
camera.FieldOfView += fovDifference * easeSpeed
end)