Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make a working top-down view camera angle?

I have a top-down view script that tracks a character called "Noob" when he moves that is called by the MoveCharacter RemoteFunction. The camera will follow but it looks all cutty and glitchy. I have seen multiple top-down games (including Dungeon Delver and Guest Quest) that have a very smooth view. I was wondering how you would do this?

I also realize that it's not using an actual persons character but this is just a test to see if I can get it to track an object correctly from a top-down perspective

This is my current attempt:

wait(1)

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
plr.Character:remove()
local camera = game.Workspace.CurrentCamera
local char = game.Workspace:WaitForChild("Noob")
local head = char.Head
local humanoid = char.Humanoid
local offset = {}
offset.x = 10
offset.y = 30
offset.z = 10

--plr.CameraMaxZoomDistance = 100
--plr.CameraMinZoomDistance = 80

Focus = function(pos, duration)
	for i = 1, 10 do
		local cf = CFrame.new(Vector3.new(
			pos.x + offset.x,
			pos.y + offset.y,
			pos.z + offset.z)
		, pos)
		
		camera:Interpolate(cf, CFrame.new(Vector3.new(pos.x, pos.y, pos.z)), duration)
	end
end

local pos = head.Position
camera.CameraType = "Scriptable"
camera.CoordinateFrame = CFrame.new(Vector3.new(pos.x + offset.x, pos.y + offset.y, pos.z + offset.z), pos)


game.Workspace.MoveCharacter.OnClientEvent:connect(function(pos)
	Focus(pos, ((head.Position - pos).magnitude) / humanoid.WalkSpeed) --The interpolation time is basically the distance it is away divided by the studs per second the character walks so that the animation will complete by the time the character gets there
end)

1 answer

This is what you need (in the starterpack!!)

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
plr.Character:remove()
local char = game.Workspace:WaitForChild("Noob")
local humanoid = char.Humanoid
 
cam = game.Workspace.CurrentCamera
cam.CameraSubject = humanoid
cam.CameraType = Scriptable

That's literally all you need. That will track the "Noob" wherever it goes and they can't do anything to their camera MAKE SURE ITS IN THE STARTER PACK!!!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.