Hello, I’m trying to make the player tilt whilst in first person running, I’ve found a solution for it out of 3rd person but how would I make it so its tilting in FIRST person.
1 Like
Can you elaborate further on what you mean by “Tilt”?
check the X direction the player is going and set the camera Z angle to it
LocalScript, StarterCharacterScripts:
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Humanoid = script.Parent:WaitForChild("Humanoid", math.huge)
local Camera = workspace.CurrentCamera
local Z = Instance.new("NumberValue") -- because using tweenservice on camera.CFrame is buggy
local Direction = 0
local CurrentTween = nil
-- change these 2 variables
local Smoothness = 0.2
local TiltLevel = 0.025
RunService.RenderStepped:Connect(function()
local ZDirection = -math.round(Humanoid.MoveDirection:Dot(Camera.CFrame.RightVector))
if ZDirection ~= Direction and CurrentTween then
CurrentTween:Pause()
CurrentTween:Destroy()
CurrentTween = nil
end
if not CurrentTween then
Direction = ZDirection
CurrentTween = TweenService:Create(
Z,
TweenInfo.new(Smoothness),
{["Value"] = ZDirection * TiltLevel}
)
CurrentTween:Play()
end
Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, Z.Value) -- you can use math.rad here
end)
exactly what i was looking for thanks!
question, how would I make the camera sway?