So I’ve developed a slide system that aims to be a similar to the sliding on the game Grace, and I’ve been having some doubts on how to make something like that.
I’ve been using a BodyVelocity, which from research is pretty antiquated, but I don’t seem to see any other alternatives, since many of the others I’ve tried like LinearBodyVelocity / AngularBodyVelocity just make the player not have a gravity.
The biggest problem I have is just that the player gets stuck to walls and cannot get “unstuck” until they stop sliding, and I’d like that to not happen at any case
So if anyone has any idea on how to make something like this, it would help a lot!
(Footage and Script below)
local plr = game.Players.LocalPlayer
local char = plr.Character
local uis = game:GetService("UserInputService")
local root = char.HumanoidRootPart
local camera = workspace.CurrentCamera
local rp = RaycastParams.new()
rp.FilterType = Enum.RaycastFilterType.Exclude
rp.FilterDescendantsInstances = {char}
local dS = 16
local cS = 0
local hasStarted = false
local s = char.Humanoid:LoadAnimation(script.slidin_anim)
local can = true
char.Humanoid.StateChanged:Connect(function(ol, new)
print("d")
if new == Enum.HumanoidStateType.Freefall then
if math.abs(char:WaitForChild("HumanoidRootPart").AssemblyLinearVelocity.Y) > 10 then
can = true
end
else
can = false
end
end)
while task.wait() do
if (uis:IsKeyDown(Enum.KeyCode.LeftControl) or uis:IsKeyDown(Enum.KeyCode.RightControl)) and char.Humanoid.FloorMaterial ~= Enum.Material.Air then
local i = 30
local slide = Instance.new("BodyVelocity")
slide.Velocity = char.HumanoidRootPart.CFrame.LookVector * i
slide.MaxForce = Vector3.new(1,0,1) * 30000
slide.Parent = root
script.slide_sfx:Play()
repeat
script.slide_sfx.PlaybackSpeed = 1 + i/100
s:Play()
char.Humanoid.CameraOffset = Vector3.new(0,0,0):Lerp(Vector3.new(0, -1.5, 0), 0.25)
slide.Velocity = char.HumanoidRootPart.CFrame.LookVector * i
local deltaY = char.HumanoidRootPart.Velocity.Y;
local deltaX = (char.HumanoidRootPart.Velocity*Vector3.new(1,0,1)).Magnitude;
local r = workspace:Raycast(char.HumanoidRootPart.Position, -Vector3.yAxis * 25, rp)
if deltaY/deltaX > 0 and can == false then
if r then
print(r.Instance)
print(r.Material)
if (r.Instance:IsA("Part") and r.Instance.Shape == Enum.PartType.Wedge) or (r.Instance:IsA("WedgePart")) then
i /= 1.025
end
end
i /= 1.005
else
if can == false then
i *= 1.02
end
end
task.wait()
until not uis:IsKeyDown(Enum.KeyCode.LeftControl) or i < 0
s:Stop()
script.slide_sfx:Stop()
char.Humanoid.WalkSpeed = 16
game.Debris:AddItem(slide, 0.05)
repeat
char.Humanoid.CameraOffset = Vector3.new(0,0,0):Lerp(Vector3.new(0, 0, 0), 0.25)
task.wait()
until char.Humanoid.CameraOffset == Vector3.new(0,0,0)
else
hasStarted = false
cS = 0
end
end