I want to create a camera where I can control the pivot point and smoothly orbit the camera in a direction when a player reaches a part of the map like kinda like Pokemon.
I am new to scripting and what I have so far is probably unpractical so any help would help! I have tried ROBLOX Documentation as well not much help as I learn better from videos.
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local OFFSET = Vector3.new(20, 20, 20)
Part1 = workspace:WaitForChild("Part1")
local region1 = true
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
player.CameraMinZoomDistance = 10
camera.FieldOfView= 45
-- Detatch the character's rotation from the camera
UserSettings().GameSettings.RotationType = Enum.RotationType.MovementRelative
local function onRenderStep()
local character = player.Character
if character then
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
-- Update the position of the camera
if region1 then
local playerPosition = humanoidRootPart.Position
local cameraPosition = playerPosition + OFFSET
camera.Focus = humanoidRootPart.CFrame
camera.CFrame = CFrame.new(cameraPosition, playerPosition) * CFrame.Angles(0, 0, 0)
Part1.Touched:Connect(function()
region1 = false
end)
end
end
if region1 == false then
local playerPosition = humanoidRootPart.Position
local OFFSET = Vector3.new (0, 20, 20)
local playerPosition = humanoidRootPart.Position
local cameraPosition = playerPosition + OFFSET
camera.CFrame = CFrame.new(cameraPosition, playerPosition) * CFrame.Angles(0, 0, 0)
end
-- Update the focus of the camera to follow the character
end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)