#Camera angle

4 messages · Page 1 of 1 (latest)

primal totem
#

you gotta show the script too yk

primal totem
torn fjord
#
local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local character = nil
local humanoid = nil


local cameraDistance = 15  
local cameraHeight = 3     
local rotationSpeed = 0.3  
local pitchAngle = -6   


local originalCameraType = camera.CameraType


local yaw = 0


local function updateCamera()
    if character and humanoid then
        
        local mouseDelta = userInputService:GetMouseDelta()

        
        yaw = yaw - mouseDelta.X * rotationSpeed  

        
        local cameraRotation = CFrame.new(character.PrimaryPart.Position)
            * CFrame.Angles(math.rad(pitchAngle), math.rad(yaw), 0)  

        
        camera.CFrame = cameraRotation * CFrame.new(0, cameraHeight, cameraDistance)  
    end
end


local function resetCamera()
    camera.CameraType = Enum.CameraType.Custom
end


player.CharacterAdded:Connect(function(char)
    character = char
    humanoid = character:WaitForChild("Humanoid")

    
    camera.CameraType = Enum.CameraType.Scriptable
    resetCamera()  
end)


game:GetService("RunService").RenderStepped:Connect(function()
    updateCamera()
end)


userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
userInputService.MouseIconEnabled = false```
#

the main thing is pitch angle is set right but when i turn the thirdperson view 180 degrees its going upwards