I am attempting at creating a custom camera script that basically acts as if you are constantly holding right click. But I cant seem to figure out the math for the camera rotation around the player. I am not the best at math so I am a little lost about this one, I tried something I thought may work but it didnt. (Youll see in my code below).
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local Camera = workspace.Camera
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
Camera.CameraType = Enum.CameraType.Scriptable
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
function UpdateCameraPosition()
Camera.CFrame = CFrame.new((Character.PrimaryPart.CFrame * CFrame.Angles(Mouse.Y/Mouse.ViewSizeY, Mouse.X/Mouse.ViewSizeX, 0)) * CFrame.new(3, 5, 5).Position, Character.PrimaryPart.Position)
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, UpdateCameraPosition)
Does anyone have any ideas? Also how in the world do you put all your code into the block? 1 line at a time? This is my first time back on this site with the new text editor.