Advertisement
oopsrainbow4

Camera Bobble Effect

Aug 24th, 2023
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. -- Local script in StarterCharacterScript
  2.  
  3. local RunService = game:GetService("RunService")
  4. local character = script.Parent
  5. local humanoid = character:WaitForChild("Humanoid")
  6.  
  7. function updateBobbleEffect()
  8.     local CurrentTime = tick()
  9.     if humanoid.MoveDirection.Magnitude > 0 then
  10.         local BobbleX = math.cos(CurrentTime * 10) * .25
  11.         local BobbleY = math.abs(math.sin(CurrentTime * 10)) * .25
  12.         local Bobble = Vector3.new(BobbleX, BobbleY, 0)
  13.        
  14.         humanoid.CameraOffset = humanoid.CameraOffset:lerp(Bobble, .25)
  15.     else
  16.         humanoid.CameraOffset = humanoid.CameraOffset * .75
  17.     end
  18. end
  19.  
  20. RunService.RenderStepped:Connect(updateBobbleEffect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement