Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

local Workspace = game:GetService("Workspace") local RunService =…

  1. User

    local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local LocalPlayer = game:GetService("Players").LocalPlayer local UserInputService = game:GetService("UserInputService") local Root = LocalPlayer.Character:WaitForChild("HumanoidRootPart") local Mouse, Camera = LocalPlayer:GetMouse(), Workspace.CurrentCamera local angleX, x, y, tilt, vX, vY, sX, sY = 0, 0, 0, 0, 0, 0, 10, 10 local TouchEnabled = UserInputService.TouchEnabled local randomX, randomY = nil, nil local function lerp(v1, v2, t) return v1 + (v2 - v1) * t end

    RunService.RenderStepped:Connect(function(dt) local velocity = Root.Velocity.magnitude if velocity > 0.02 then dt *= 60 randomX = math.random(1, 2) randomY = math.random(1, 2) --x(10,15), y(5,10) vX = dt <= 2 and lerp(vX, math.cos(tick() * 0.5 * randomX) * (math.random(1, 1) / 200) * dt, 0.05 * dt) or 0 vY = dt <= 2 and lerp(vY, math.cos(tick() * 0.5 * randomY) * (math.random(1, 1) / 200) * dt, 0.05 * dt) or 0

    	Camera.CFrame *= CFrame.Angles(0, 0, math.rad(angleX))
    		* CFrame.Angles(math.rad(math.clamp(x * dt, -0.15, 0.15)), math.rad(math.clamp(y * dt, -0.5, 0.5)), tilt)
    		* CFrame.Angles(math.rad(vX), math.rad(vY), math.rad(vY * 10))
    
    	tilt = math.clamp(lerp(tilt, -Camera.CFrame:VectorToObjectSpace((Root and Root.Velocity or 
    		Vector3.new()) / math.max(LocalPlayer.Character.Humanoid.WalkSpeed, 0.01)).X * 0.05, 0.1 * dt), -0.05, 0.05)
    
    	if not TouchEnabled and dt < 2 then
    		angleX = lerp(angleX, math.clamp(UserInputService:GetMouseDelta().X / dt * 0.15, -2.5, 2.5), 0.25 * dt)
    	end x = lerp(x, math.sin(tick() * sX) / 5 * math.min(1, sY / 10), 0.25 * dt)
    	y = velocity > 1 and lerp(y, math.cos(tick() * 0.5 * math.floor(sX)) * (sX / 200), 0.25 * dt) or lerp(y, 0, 0.05 * dt)
    	sX, sY = velocity > 12 and 20 or (velocity > 0.1 and 12 or 0), velocity > 0.1 and 18 or (velocity > 0.1 and 14 or 0)
    end
    

    end)

    how can i reduce the camera's bobbing intensity

  2. Assistant

    Reducing the camera's bobbing intensity requires adjusting the magnitude of the calculations that contribute to the camera's movement. In the provided code, bobbing is primarily controlled through the variables vX, vY, x, y, and tilt. These variables are influenced by math.cos, math.sin, and other adjustments scaled by multipliers.

    To reduce the bobbing intensity, you can decrease the multipliers involved. Here's how you can adjust the relevant sections of your code:

    1. Adjust vX and vY:

      Reduce the impact of the random values coming from math.cos.

      vX = dt <= 2 and lerp(vX, math.cos(tick() * 0.5 * randomX) * (math.random(1, 1) / 500) * dt, 0.05 * dt) or 0 -- changed divisor from 200 to 500
      vY = dt <= 2 and lerp(vY, math.cos(tick() * 0.5 * randomY) * (math.random(1, 1) / 500) * dt, 0.05 * dt) or 0 -- changed divisor from 200 to 500
      
    2. Adjust x and y:

      Reduce the impact of the math.sin and math.cos calculations.

      x = lerp(x, math.sin(tick() * sX) / 10 * math.min(1, sY / 10), 0.25 * dt) -- changed divisor from 5 to 10
      y = velocity > 1 and lerp(y, math.cos(tick() * 0.5 * math.floor(sX)) * (sX / 400), 0.25 * dt) or lerp(y, 0, 0.05 * dt) -- changed divisor from 200 to 400
      
    3. Adjust tilt:

      Reduce the influence of Root.Velocity.

      tilt = math.clamp(lerp(tilt, -Camera.CFrame:VectorToObjectSpace((Root and Root.Velocity or Vector3.new()) / math.max(LocalPlayer.Character.Humanoid.WalkSpeed, 0.01)).X * 0.025, 0.1 * dt), -0.05, 0.05) -- changed multiplier from 0.05 to 0.025
      

    By making these adjustments, you effectively reduce the intensity of the camera bobbing. The adjustments are simply reducing the divisors and multipliers in the calculations, which scales down the modifications to the camera's viewpoint. You can fine-tune these values further if you find that the bobbing is still too intense or not intense enough.