How would I go about making a top down game camera?

So I’m making a zombie shooter type game and I was wondering how I would go about making a top down camera similar to these!
Made my @Kennycell

fe2e8a6e872dd73461dbd49915bdc25fe8881e90_2_690x356

39a9f4f94a736d3ac65f1a43b307b8f770b98313_2_690x352

3e04ce15f038b38dab9493455ba66c71c7782741_2_690x357

Note: I am a dev in training and I can build but when it comes to scripting I can read and edit scripts to fit what I want them to do but I cant create scripts from scratch

5 Likes

Lock the camera and set the FoV somewhere in the 15-30 from your preference.

original 70 FoV
image

20 FoV

image
Properties of the FieldofView “Camera” can be found in Workspace

To lock the camera you could set the CameraType property to Enum.CameraType.Scriptable
Then bind a function to the RenderStepped event of RunService that sets the camera’s CFrame.

If you wanted the camera to look down diagonally in an isometric style you could construct the CFrame like this:

local lookAt = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local camDistance = 20
workspace.CurrentCamera.CFrame = CFrame.new(lookAt) * CFrame.fromOrientation(math.rad(-45), math.rad(45), 0) * CFrame.new(0, 0, camDistance)
2 Likes

Update:
Wrote up a sample localscript:

local rs = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local distance = 30
local cf = CFrame.fromOrientation(math.rad(-45), math.rad(45), 0) * CFrame.new(0, 0, distance)

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

rs:BindToRenderStep("camLock", Enum.RenderPriority.Camera.Value + 1, function()
	if (player.Character and player.Character:FindFirstChild("HumanoidRootPart")) then
		workspace.CurrentCamera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * cf
	end
end)

3 Likes

When I used that code in a script in the camera, it didn’t work. (I’m a total scripting noob so please explain as well as you can)

1 Like

From the wiki page on LocalScripts:

A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service

What I normally do is put them in the PlayerScripts folder inside game.StarterPlayer, if the script isn’t associated with any tool or GUI object.

2 Likes

Does it matter which object I put it in?

1 Like

As long as it is in any of those places where local scripts can run, although StarterPlayer.StarterPlayerScripts is the most appropriate place for it in my opinion.

Okay! Thanks for the help! :heart::heart::heart:

1 Like