Camera and character movement for isometric camera script

I’ve been trying this isometric camera tutorial implementing the code provided with some slight changes:

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

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

local CAMERA_DEPTH = 64
local HEIGHT_OFFSET = 25

camera.FieldOfView = 40

local function updateCamera()
	local character = player.Character
	if character then
		local root = character:FindFirstChild("HumanoidRootPart")
		if root then
			local rootPosition = root.Position + Vector3.new(0, HEIGHT_OFFSET, 0)
			local cameraPosition = rootPosition + Vector3.new(CAMERA_DEPTH, CAMERA_DEPTH, CAMERA_DEPTH)
			camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
		end
	end
end

RunService:BindToRenderStep("IsometricCamera", Enum.RenderPriority.Camera.Value + 1, updateCamera)

And looks like this: https://gyazo.com/…

The code mentioned above fixes the camera with CFrame.lookAt “disabling” the rotation along the Y axis. Is there any possible way to add this functionality again?

Additionally, how can I make the character to always look “north” relative to the camera view? I need this in order to make the camera always point to the back of the character. My intention is that the character auto-rotates when the camera turns (using the RMB, swipe in mobile or camera thumbstick with controller) and that the direction of the movement is relative to camera view, not to world (with keyboard: WASD should be NorthEastSouthWest according to camera view).

1 Like

Did you ever figure out how to rotate the camera while keeping the isomentric angle?

Yes, I’m using OrbitalCamera now which does exactly that. The problem is that you can no longer control the camera position which is stuck by default. What I did is customize the OrbitalCamera module script located here when you hit play in Studio,
Screenshot 2024-08-26 171338

and editing the output of the following function

-- [[ Update ]]--
function OrbitalCamera:Update(dt: number): (CFrame, CFrame)
	return newCameraCFrame, newCameraFocus
end

I found this method to be simpler that attempting to configure the movement of the character because the orbital camera does it already for any type of input (keyboard, mouse, controller and VR).

1 Like