I have created a local script in StarterCharacterScripts to emulate the wall-sliding ability from Egg Hunt 2018. However, it has not gone quite well. I am having trouble with collision detecting especially when free falling and the script has me wall sliding with the floor instead of walls.Here is my script and thanks for viewing:
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HRP = Character:WaitForChild("HumanoidRootPart")
local RunService = game:GetService("RunService")
local Debounces = {["Climbing"] = false}
local Params = RaycastParams.new()
Params.CollisionGroup = "Climbable"
Params.FilterDescendantsInstances = {Character}
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.IgnoreWater = true
local BV = Instance.new("BodyVelocity")
BV.Name = "WallClimbBV"
BV.MaxForce = Vector3.new(4000, 2500, 4000)
BV.P = math.huge
BV.Velocity = Vector3.new()
local BG = Instance.new("BodyGyro")
BG.Name = "WallClimbBG"
BG.CFrame = CFrame.new()
BG.D = 100
BG.MaxTorque = Vector3.new(1, 1, 1) * math.huge
BG.P = 3000
HRP.Touched:Connect(function(Hit)
if not Debounces["Climbing"] then
local Origin = HRP.Position
local Direction = HRP.CFrame.LookVector
local Result = workspace:Raycast(Origin, Direction, Params)
if Result then
Debounces["Climbing"] = true
HRP.CFrame = CFrame.new(HRP.CFrame.p) * CFrame.fromEulerAnglesXYZ(0, math.rad(20), 0)
Humanoid.AutoRotate = false
Humanoid.PlatformStand = true
BV.Parent = HRP
BG.Parent = HRP
local Face = CFrame.new(Result.Position + Result.Normal, Result.Position)
repeat
RunService.RenderStepped:Wait()
BG.CFrame = Face or CFrame.new()
if HRP.Position.Y > Result.Instance.Size.Y + 3 or (HRP.Position.Y <= (Result.Instance.Position * CFrame.new(0, -Result.Instance.Size.Y / 2, 0)).p) then
Debounces["Climbing"] = false
BG.Parent = nil
BV.Parent = nil
end
-- Calculate sliding velocity
local slideDirection = (Result.Normal:Cross(Vector3.new(0, 1, 0))).unit
local slideVelocity = slideDirection * 10 -- Adjust this value to control the sliding speed
BV.Velocity = slideVelocity
until not Debounces["Climbing"]
Humanoid.AutoRotate = true
Humanoid.PlatformStand = false
end
end
end)