local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
local char = script.Parent
local humanoid = char:WaitForChild("Humanoid")
humanoid.AutoRotate = false
local hrp = char:WaitForChild("HumanoidRootPart")
local x = 0
local y = 0
local offset = Vector3.new(3, 3, 10)
uis.InputChanged:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseMovement then
x = x - input.Delta.X
y = math.clamp(y - input.Delta.Y*0.4, -75, 75)
hrp.CFrame = hrp.CFrame * CFrame.Angles(0, math.rad(-input.Delta.X), 0)
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local startCFrame = CFrame.new((hrp.CFrame.Position)) * CFrame.Angles(0, math.rad(x), 0) * CFrame.Angles(math.rad(y), 0, 0)
local cameraCFrame = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, offset.Z))
local cameraDirection = startCFrame:ToWorldSpace(CFrame.new(offset.X, offset.Y, -10000))
camera.CFrame = CFrame.new(cameraCFrame.Position, cameraDirection.Position)
end)
I just want my third person camera to work properly.
Technically, I found a solution for this. I see the code: uis.MouseBehavior = Enum.MouseBehavior.LockCenter. Simply remove the line! The problem should be fixed!
The Character rotates when it gets touched by something
To fix this, simply remove the code: humanoid.AutoRotate = false. Then the problem should be fixed.
AutoRotate sets whether or not the Humanoid will automatically rotate to face in the direction they are moving in.
Didn’t work the camera works like the default now, I wanted the character to be locked like a shift lock without it getting rotated when it get touched by something, I apprichiate the Idea tho!
The Character rotates when it gets touched by something
To fix this, simply remove the code: humanoid.AutoRotate = false . Then the problem should be fixed.
AutoRotate sets whether or not the Humanoid will automatically rotate to face in the direction they are moving in.
local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation