How to make movement go faster as the camera distance gets bigger

This post is related to my previous post.

As the cameraDistance variable gets bigger, how do I make the player move faster?

1 Like

You would need something called a ratio

RunService.Heartbeat:Connect(function(deltaTime)
   local distance = (game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.Position - workspace.CurrentCamera.CFrame.Position).Magnitude
   local ratio = distance / 100

   game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 * ratio
end)

The further the player is away from the camera the faster they will move, I put 16 because that’s what it’ll scale the walkspeed from

Hello again!

Speaking in respect to your previous topic here is the breakdown:

  • First of all you are going to need the cameraDistance variable.
  • Second, you are going to need to use the ratio between the current cameraDistance and it’s upper limit i.e maximum distance. Something like so;
-- In the RunService loop.
local distanceFactor = cameraDistance/maximum_cameraDistance
  • Now we are just going to apply it to the player’s walkspeed.
Character.Humanoid.WalkSpeed = 16*distanceFactor

This would scale it linearly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.