While camera is following head movement Character is Glitching

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want the camera track the head without any issue

  2. What is the issue? İssue can be seen in the video camera glitches out and turns the character

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local isAlive = true
local isRunning = false
local isVaulting = false
local isDashing = false
local isLanded = true
local isRolling = false
local isBracing = false


RunService.Heartbeat:Connect(function()
    if Player.Character:WaitForChild("Humanoid").Health == 0 then
        isAlive = false
    else
        isAlive = true
    end
    -- print(isRunning, isDashing, isVaulting, isLanded)
    if Character.Head.LocalTransparencyModifier == 1 then
        if isVaulting then
            local headRotation = Character.Head.CFrame

            local FollowCamera = headRotation + headRotation.LookVector * 5 

            Camera.CFrame = Camera.CFrame:Lerp(FollowCamera, 0.1)
        elseif isDashing then
            local headRotation = Character.Head.CFrame

            local FollowCamera = headRotation + headRotation.LookVector * 5 

            Camera.CFrame = Camera.CFrame:Lerp(FollowCamera, 0.1)
        elseif isBracing then
            local headRotation = Character.Head.CFrame

            local FollowCamera = headRotation + headRotation.LookVector

            Camera.CFrame = Camera.CFrame:Lerp(FollowCamera, 1)
        end
    else
       -- not in first person
end
end)

3 Likes

Try setting the player humanoids AutoRotate property to False while the animation is playing in first person.

as you can see this time camera went back(not turning downside idk how to explain think like you are rolling in real life and then ur eyes see 180 degrees down)

1 Like

when you lerp with a value of 1 it just sets it to the goal
also, you are just making the camera follow the head but slower idrk how thats working out for ya

1 Like

Im trying to make the camera follow heads movement and angles. Also why is it slower ? And 1 is just value for test

1 Like

the lerp function returns a cframe x% of the way to the other cframe
by putting 1 (which is 100%) you are doing the same as Camera.CFrame = FollowCamera

1 Like

Umm yeah ur right. But I couldnt see any other way to do it. Like how do I make the camera turn any possible way with the angles of the head. Because camera makes it self turn back when it goes to 91 on the Y axis. Also it makes it much smoother(when the value is not set to 1)

1 Like

this might not work but:
whenever you are rolling, add the delta time to a variable called timeElapsed and using that variable rotate the camera like this:

camera.CFrame = head.CFrame * CFrame.Angles(0, 0, math.rad(15 * timeElapsed))

you might have to change which direction/axis the angle is getting changed by, you can also lerp it

2 Likes

Soo I did this and it seems like nothing changed it still does that camera clipping on random directions

1 Like

I think I found the fix but how do I use this on the situation I am in. Can anyone explain ?

Please someone help :skull: , asd123

If you want the camera to be locked to the head while the player is in first person and the animation is playing, just set the cameras position to the heads position and set it’s orientation to the look vector of your head every frame. You can use CFrame.lookAlong() to calculate the camera CFrame.

This was my solution

    elseif isBracing then
        local headRotation = Character.Head.CFrame

        local FollowCamera = headRotation + headRotation.LookVector / math.pi * 180 
        Camera.CameraType = Enum.CameraType.Scriptable ---- Made the camera type scriptable so it not following player 
        Camera.CFrame = Camera.CFrame:Lerp(headRotation, 1)
    end

------ Keyboard input stuff etc.

if input.KeyCode == Enum.KeyCode.LeftControl then

    if isAlive and isLanded == true and isVaulting == false and isRolling == false then --and isBracing == false then
        isBracing = true
        Humanoid.AutoRotate = false --- I added this new line that stops the glitching
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.