Birds-eye view camera

Hi all.

I’ve mainly been a builder for most of my time on Roblox, however, I’ve come across a situation where I need to script on a specific project.

It’s basically an ‘interactive map’ based game. I’m trying to get the default camera view to be sort-of like a birds eye view, where the rotation of the view is fixed on the ground, and you’re able to move your camera around using WASD and zoom in and out (to an extent) using the mouse wheel.

How do I do this?

2 Likes
local Game = game
local Workspace = workspace
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Workspace.CurrentCamera

local function OnRenderStep()
	local Pivot = Character:GetPivot().Position
	local Distance = (Camera.CFrame.Position - Pivot).Magnitude
	Camera.CFrame = CFrame.lookAt(Pivot + Vector3.new(0, Distance, 0.5), Pivot)
end

RunService.RenderStepped:Connect(OnRenderStep)

Where do I put this? How do I set it up further?

This should be in a LocalScript. You can put it in StarterPlayerScripts.

Yes but what else do I do? I have no scripting experience at all. I don’t know what else I must do, I’ve put a localscript in StarterPlayerScripts, it doesn’t work, nothing changes.

You need to add this at the bottom of the script:

RunService.RenderStepped:Connect(OnRenderStep)

And also implement this: (above the function)

repeat task.wait()
    Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable

Where do I add this?

Another thing, it’s kinda working but not exactly like I want it, I need there to be a zoom limit, aswell as a boundary. I basically want it to be a camera like most strategy games.

1 Like

It should be At the top of the script.

It would also be cool if the camera moved when you moved your mouse to the edge of the screen.

Alot of free models are in the toolbox. You can just get them

You can search that up, this forum is not for script requesting.

1 Like

The camera’s type should remain as ‘Custom’.

Here’s the script with a clamp incorporated, check the comments for further information.

local Game = game
local Workspace = workspace
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = Workspace.CurrentCamera

local function OnRenderStep()
	local Pivot = Character:GetPivot().Position
	local Distance = math.clamp((Camera.CFrame.Position - Pivot).Magnitude, 10, 64) --10 studs is the minimum height and 64 studs is the maximum height.
	Camera.CFrame = CFrame.lookAt(Pivot + Vector3.new(0, Distance, 0.5), Pivot)
end

RunService.RenderStepped:Connect(OnRenderStep)

As for moving the mouse to the edge of the screen to move the camera I’d recommend hiring someone from here to do that.

you don’t need this because “RunService” runs at what ever frame rate you are using