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

How to make a top down shooter camera?

I don't know how to make a top down shooter camera, and the tutorials I've found don't help with controlling the camera with your mouse.

How do I make a top down shooting camera?

1 answer

-- Place into StarterPlayerScripts as a LocalScript --

local Player = game:GetService("Players").LocalPlayer
local Character
local Humanoid
local Camera = workspace.CurrentCamera

local RunService = game:GetService("RunService")

-- Configurable Settings
local Dampening = 1000 -- Higher number makes it take longer to reach its destination
local Power = 10000 -- Higher number means more power
local MaxForce = Vector3.new(4000, 4000, 4000) -- Max amount of power that can be applied on each axis
--------------------------------------------------------------------------------------------

function OnCharacterAdded(AddedCharacter)
	if AddedCharacter == nil then
		repeat wait() until AddedCharacter ~= nil
	end
	
	if AddedCharacter.Parent == nil then
		repeat wait() until AddedCharacter.Parent ~= nil
	end
	
	if AddedCharacter ~= nil and AddedCharacter.Parent ~= nil then
		Character = AddedCharacter
		Humanoid = Character:WaitForChild("Humanoid")
		
		Camera.CameraType = Enum.CameraType.Scriptable
		
		CreateCameraPositionPart()
		RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, UpdateCameraPosition)
	end
end

function UpdateCameraPosition()
	Character.CameraPositionPart.BodyPosition.Position = Character.PrimaryPart.Position + Vector3.new(-1, 25, 0)
	Camera.CFrame = CFrame.new(Character.CameraPositionPart.Position, Character.CameraPositionPart.Position - Vector3.new(-1, 25, 0))
end

function CreateCameraPositionPart()
	local CameraPositionPart = Instance.new("Part")
	CameraPositionPart.CanCollide = false
	CameraPositionPart.Transparency = 1
	CameraPositionPart.Name = "CameraPositionPart"
	CameraPositionPart.Parent = Character
	
	local CameraBodyPosition = Instance.new("BodyPosition")
	CameraBodyPosition.D = Dampening
	CameraBodyPosition.P = Power
	CameraBodyPosition.MaxForce = MaxForce
	CameraBodyPosition.Parent = CameraPositionPart
	
	return
end

Player.CharacterAdded:Connect(OnCharacterAdded)

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