How do I add camera sway whenever the player is moving?

i’m trying to add camera sway, but i don’t really know how to do that

all i have as of right now is this:

local plr = game:GetService("Players").LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local RootPart = Char:WaitForChild("HumanoidRootPart")
local Humanoid = Char:WaitForChild("Humanoid") -- i don't think i'll need this

local Camera = workspace:WaitForChild("Camera")


if RootPart.AssemblyLinearVelocity.Magnitude > 1 then
	
end

you can have a variable holding a number value
then multiply ur sway axis by that number
for example

local moving : number
moving = humanoid.MoveDirection.Magnitude > 0 and 1 or 0
local swayX = numbers * moving
local swayY = numbers * moving

you define moving as a number and then change it to humanoid??

i’m not really following

also, why use humanoid.MoveDirection.Magnitude? is there a difference to that and RootPart.AssemblyLinearVelocity?

oh i get it

(YES I KNOW I SAID HUMANOID)

i was confused about the local moving : number :sob:

no? its a statement checking if humanoid.MoveDirection.Magnitude is over 0, if so it sets the variable to 1 else it sets it to 0
Humanoid.MoveDirection is a Unit vector and it updates faster which is good for our situation

Are you talking about the Camera Z Axis (Roll) swaying to the direction the Player is turning, or making the camera Bobble (Sway) when the Player is walking?

bobble (character limti08adhgoifdhgois[dhgoi[usfdhgfd)

sorry it was pretty confusing for me at first!!!

There’s actually a code sample on the documentation page that you can use, along with a explanation (kind of) on how it works.

1 Like

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