Drvays

Camera Shake

May 24th, 2021
30,808
1
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 1 0
  1. local runService = game:GetService("RunService")
  2. local character = script.Parent
  3. local humanoid = character:WaitForChild("Humanoid")
  4.  
  5. function updateBobbleEffect()
  6. local currentTime = tick()
  7. if humanoid.WalkSpeed >= 16 and humanoid.Sit == false then
  8. if humanoid.MoveDirection.Magnitude > 0 then
  9. local bobbleX = math.cos(currentTime * 10) * .35
  10. local bobbleY = math.abs(math.sin(currentTime * 10)) * .35
  11. local bobble = Vector3.new(bobbleX, bobbleY, 0)
  12. humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25)
  13. else
  14. humanoid.CameraOffset = humanoid.CameraOffset * .75
  15. end
  16. end
  17. end
  18. runService.RenderStepped:Connect(updateBobbleEffect)
Advertisement
Comments
Add Comment
Please, Sign In to add comment