the current speed to affect headbob after?
my script is
01 | local runService = game:GetService( "RunService" ) |
03 | local character = script.Parent |
04 | local pos = character.HumanoidRootPart.Position |
05 | local humanoid = character:WaitForChild( "Humanoid" ) |
07 | function updateHeadBobble() |
08 | local currentTime = tick() |
09 | if humanoid.MoveDirection.Magnitude > 0 then |
10 | pos = character.HumanoidRootPart.Position |
12 | currentSpeed = (pos-character.HumanoidRootPart.Position).magnitude |
14 | local bobbleX = math.cos(currentTime * 7.5 ) * currentSpeed |
15 | local bobbleY = math.abs(math.sin(currentTime * 7.5 )) * currentSpeed |
17 | local bobble = Vector 3. new(bobbleX, bobbleY, 0 ) |
18 | humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, 0.25 ) |
20 | humanoid.CameraOffset = humanoid.CameraOffset * 0.75 |
24 | runService.RenderStepped:Connect(updateHeadBobble) |
It works but it happens after i move but i want the headbob to happen whilst im moving
Anyone got any idea???