You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want the camera track the head without any issue
What is the issue? İssue can be seen in the video camera glitches out and turns the character
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)
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)
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
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
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)
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:
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.
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