Hello there! Thanks for anyone who responds or reads this post.
I am making a horror game and want to make smooth first-person camera movements, so the game feels more realistic.
Here’s my current view bobbing code:
local input = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local mouse = player:GetMouse()
input.MouseIconEnabled = false
local rs = game:GetService("RunService")
local humanoid = player.Character:WaitForChild("Humanoid")
rs.RenderStepped:Connect(function(delta)
if humanoid.MoveDirection.Magnitude > 0 then
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(Vector3.new(0,math.sin(tick()*10)/3,0),delta)
else
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(Vector3.new(0,math.sin(tick()*3)/7,0),delta)
end
game.ReplicatedStorage.Events.PlayerLookDir:FireServer(camera.CFrame.Rotation)
end)
Thats my view bobbing code.
Anywhere I look I can’t find a correct way to do the smooth movements. Someone please help me, thanks for all your help.
Edit:
Theres some code on the server that moves the player head to look in the direction they are looking, thats what that last line of code does.