I made a simple script to handle camera swaying for first person (breathing, walking, running.) My issue is when you go from walking to idling, it snaps into position.
Video:
Code:
local RunService = game:GetService("RunService")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humrp = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")
local Cam = workspace.CurrentCamera
player.CameraMode = Enum.CameraMode.LockFirstPerson
Cam.FieldOfView = 90
hum.CameraOffset = Vector3.new(0, 0.25, -1)
RunService.RenderStepped:Connect(function()
local sin = math.sin(time() * 10) / 4
local cos = math.cos(time() * 5) / 2
local offset : Vector3 = Vector3.new(0,0,0)
if hum.MoveDirection.Magnitude > 0 then
if hum.WalkSpeed <= 16 then
offset = Vector3.new(cos, sin, -1)
elseif hum.WalkSpeed > 16 then
local sin = math.sin(time() * 12) / 2
local cos = math.cos(time() * 6) / 4
offset = Vector3.new(cos * 2, sin, -1)
end
else
local sin = math.sin(time() * 3) / 6
local cos = math.cos(time() * 1) / 6
offset = Vector3.new(cos, sin, -1)
end
hum.CameraOffset = Vector3.new(0, 1, 0) + offset
end)