Hello everyone, it’s me. CalypsoGames. How will I be able to implement Clash Of Clans’ camera system? If you don’t know what Clash Of Clans’ is. It is a Casual Simulator game, the purpose of the game is to build your own village and attack other online players. Other example of what I’m talking about is SimCity’s Camera System.
I tried this:
game.Workspace.CurrentCamera.Orthographic = true
local initialCameraPosition = Vector3.new(0, 10, 0)
local minZoom = 5 -- Minimum zoom level
local maxZoom = 15 -- Maximum zoom level
local currentZoom = 10 -- Initial zoom level
local UserInputService = game:GetService("UserInputService")
local zoomSpeed = 0.5
local panSpeed = 5 -- Adjust panning speed
local villageCenter = game.Workspace.VillageCenter
function Start()
game.Workspace.CurrentCamera.CFrame = CFrame.new(initialCameraPosition)
game.Workspace.CurrentCamera.FieldOfView = currentZoom
end
function Update()
currentZoom = currentZoom - UserInputService.MouseWheel * zoomSpeed -- Adjust zoom speed
currentZoom = math.clamp(currentZoom, minZoom, maxZoom)
game.Workspace.CurrentCamera.FieldOfView = currentZoom
end
function Updates()
local horizontalInput = UserInputService.MouseDelta.x
local verticalInput = UserInputService.MouseDelta.y
local panDirection = Vector3.new(horizontalInput, 0, verticalInput)
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.new(panDirection * panSpeed * 0.1)
end
function Updated()
local currentRotation = game.Workspace.CurrentCamera.CFrame:ToEulerAnglesXYZ()
local desiredRotation = Vector3.new(math.rad(45), math.rad(45), 0)
local rotationDiff = desiredRotation - currentRotation
local rotationSpeed = 2 -- Adjust the rotation speed
game.Workspace.CurrentCamera.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(rotationSpeed * rotationDiff.x, rotationSpeed * rotationDiff.y, rotationSpeed * rotationDiff.z)
end
function Updating()
local desiredPosition = Vector3.new(villageCenter.Position.X, game.Workspace.CurrentCamera.CFrame.Position.Y, villageCenter.Position.Z)
game.Workspace.CurrentCamera.CFrame = CFrame.new(desiredPosition, villageCenter.Position)
end
This code is in a localscript inside a CameraPart I created.