You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Movement like in Doom where you would slip once you release the movement key slowly stop -
What is the issue? Include screenshots / videos if possible!
im having trouble thinking of ways to do it, im not that experienced in lua
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried to look, only found guides about inertia and smooth movement
what i have so far
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoid.AutoRotate = false
local bodyVel = Instance.new("BodyVelocity")
bodyVel.Velocity = Vector3.new(0, 0, 0)
bodyVel.MaxForce = Vector3.new(10000, 0, 10000)
bodyVel.P = 1250
bodyVel.Name = "SlipperyMovement"
bodyVel.Parent = hrp
local moveDirection = Vector3.zero
local speed = 14
local acceleration = 0.5
local friction = 0.8
local velocity = Vector3.zero
local keysPressed = {}
UserInputService.InputBegan:Connect(function(input, gpe)
if gpe then return end
keysPressed[input.KeyCode] = true
end)
UserInputService.InputEnded:Connect(function(input)
keysPressed[input.KeyCode] = false
end)
RunService.RenderStepped:Connect(function()
local cam = workspace.CurrentCamera
local forward = Vector3.new(cam.CFrame.LookVector.X, 0, cam.CFrame.LookVector.Z).Unit
local right = Vector3.new(cam.CFrame.RightVector.X, 0, cam.CFrame.RightVector.Z).Unit
moveDirection = Vector3.zero
if keysPressed[Enum.KeyCode.W] then moveDirection += forward end
if keysPressed[Enum.KeyCode.S] then moveDirection -= forward end
if keysPressed[Enum.KeyCode.A] then moveDirection -= right end
if keysPressed[Enum.KeyCode.D] then moveDirection += right end
if moveDirection.Magnitude > 0 then
moveDirection = moveDirection.Unit
velocity = velocity:Lerp(moveDirection * speed, acceleration)
else
velocity *= friction
end
bodyVel.Velocity = Vector3.new(velocity.X, 0, velocity.Z)
end)