I am making a custom camera system, and the only problem I've come across so far is that if your mouse moves off screen, it doesn't allow it to rotate further. Is there something I can use to get the Mouse-Movement-Direction with LockCenter? (InputChanged fires, though I don't know how to get the direction of the mouse)
Code:
wait(2)
local Player=game.Players.LocalPlayer
local Input=game:GetService("UserInputService")
local Run=game:GetService("RunService")
local Mouse=Player:GetMouse()
local Camera=workspace.CurrentCamera
local Character=Player.Character
local Sensitivity=1
local CAX=0
local DAX=0
local CAY=0
local DAY=0
Run.RenderStepped:connect(function()
CAX=CAX+((DAX/3)*Sensitivity)
CAY=CAY+((DAY/3)*Sensitivity)
DAX=0
DAY=0
if CAY>80 then CAY=80 end
if CAY<-50 then CAY=-50 end
Camera.CoordinateFrame=CFrame.new(Character.Head.Position)*CFrame.Angles(0,math.rad(CAX),0)*CFrame.Angles(math.rad(CAY),0,0)
--[[
local CF=CFrame.new(Character.Head.Position)*CFrame.Angles(0,math.rad(CAX),0)*CFrame.Angles(math.rad(CAY),0,0)
local x,y,z,r1,r2,r3,r4,r5,r6,r7,r8,r9=CF:components()
Camera:Interpolate(CFrame.new(x,y,z),CFrame.new(r1,r5,r9),.1)
--]]
end)
Camera.CameraType="Scriptable"
Input.MouseBehavior=Enum.MouseBehavior.LockCenter
local PrevX=Mouse.X
local PrevY=Mouse.Y
Input.InputChanged:connect(function(Input,Bool)
if Input.UserInputType==Enum.UserInputType.MouseMovement then
local X=Input.Position.X
local Y=Input.Position.Y
--Old code using Mouse.Move
if X>PrevX then
DAX = PrevX - X
PrevX=X
elseif X<PrevX then
DAX = PrevX - X
PrevX=X
end
if Y>PrevY then
DAY = PrevY - Y
PrevY=Y
elseif Y<PrevY then
DAY = PrevY - Y
PrevY=Y
end
end
end)
