Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Char = LocalPlayer.Character
- local Humanoid = Char:WaitForChild("Humanoid")
- local HumanoidRootPart = Char:WaitForChild("HumanoidRootPart")
- local LastPosition = HumanoidRootPart.Position
- local IntensityX = 0.8
- local IntensityY = 1.15
- local Smoothness = 0.10
- RunService.Heartbeat:Connect(function(FrameTime)
- local CurrentTime = workspace:GetServerTimeNow()
- local CurrentPosition = HumanoidRootPart.Position
- local CurrentDistance = (CurrentPosition - LastPosition).Magnitude
- if Humanoid.MoveDirection.Magnitude > 0 then
- local CurrentSpeed = math.floor(CurrentDistance / FrameTime) * 10^-2
- local X = math.cos(CurrentTime * CurrentSpeed) * IntensityX
- local Y = math.abs(math.sin(CurrentTime * CurrentSpeed )) * IntensityY
- Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(Vector3.new(X,Y,0),Smoothness)
- LastPosition = CurrentPosition
- else
- Humanoid.CameraOffset = Humanoid.CameraOffset * (1 - Smoothness)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement