I Need A Script That
Positions and Rotates the Camera in a Sphere-Like Pattern around a specified 3D Point.
The White Cube in the Middle represents a specified 3D Point somewhere in the World. The Red Sphere and the Cameras around it showcase the full range of motion that the Camera has.
Core Idea:
-- Services
local UserInputService = game:GetService('UserInputService')
local RunService = game:GetService('RunService')
-- Variables
local Dragging = false
local LastPosition
local Camera = workspace.CurrentCamera
-- Camera Settings
local Distance = 5
local Sensitivity = 0.02
local CenterPoint = Vector3.new(0,0,0)
Camera.CameraType = Enum.CameraType.Scriptable
-- Camera Update
local function UpdateCamera(Delta)
-- Calculate Camera Position here
end
-- Cursor Dragging
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton2 then
Dragging = true
LastPosition = input.Position
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton2 then
Dragging = false
end
end)
UserInputService.InputChanged:Connect(function(input)
if Dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local Delta = input.Position - LastPosition
UpdateCamera(Delta)
LastPosition = input.Position
end
end)
If you have any Questions, Ideas or Solutions, write a comment!
