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 smoother top-down script?

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?

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 discussion is preserved as it was. New answers, comments, and votes are closed.