How to make wall jump/slide

Heyo currently trying to make a wall jump/wall slide system like the ones in mario games however I’m a bit stuck I kind of have no idea what I’m doing. I’ve reused a wall climbing script and I’ve been adjusting things to get it the way I want, but it’s a bit buggy.

local Face = nil --not sure what this does in the script

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) --seems to be a good force to be affected by gravity still
BV.P = math.huge
BV.Velocity = Vector3.new()
--BV.Name = ("Climb Speed")

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)
	print("TOUCHED")
	local Face = nil
	
	if not Debounces["Climbing"] then
		--warn("START WALL CLIMB")
		local Origin = HRP.Position
		local Direction = HRP.CFrame.LookVector

		local Result = workspace:Raycast(Origin, Direction, Params)
		if Result then
			Debounces["Climbing"] = true
			_G[Player.Name]:PlayAnimation("WallJump")
			--HRP.CFrame = CFrame.new(HRP.CFrame.p, Vector3.new(HRP.Position.X - Result.Normal.X, HRP.Position.Y, HRP.Position.Z - Result.Normal.Z))
			HRP.CFrame = CFrame.new(HRP.CFrame.p)* CFrame.fromEulerAnglesXYZ(0, math.rad(20), 0)
			Face = CFrame.new(Result.Position+Result.Normal, Result.Position)

			Humanoid.AutoRotate=false
			Humanoid.PlatformStand=true

			BV.Parent=HRP
			BG.Parent=HRP

			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
					_G[Player.Name]:StopAnimation("WallJump")
					BG.Parent=nil
					BV.Parent=nil
					Face=nil
				end
			until (not Debounces["Climbing"])

			Humanoid.AutoRotate=true
			Humanoid.PlatformStand=false
		end
	end
end)

I’m mostly stuck with this part at the moment

				--When you reach the top of the part
				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
					_G[Player.Name]:StopAnimation("WallJump")
					BG.Parent=nil
					BV.Parent=nil
					Face=nil
				end

I’m trying to make it so when the player is above or below the part I want them to stop sliding on it

This is how it currently looks

6 Likes

You could use the player’s FloorMaterial? That’s something I’d look into for this kind of issue. : D

humanoid:GetPropertyChangedSignal("FloorMaterial"):Connect(function()
    --touch ground? idk. check here.
end)
2 Likes

Here’s a way to detect if a player is above or below a part.

Cast an extra ray above the ray (Maybe where the head area is) you’re already casting, and if it doesn’t return a wall, then that means you’ve reached the top of the wall.

Vica versa for if you’re below the part.

1 Like

You might need to predict when they will go up/ down with a formula;

local speed = BV.Velocity 
-- Result.Instance.Size/2 this will get the up position just use negative for down
local distance = ( (Result.Instance.Position * Vector3.new(0,Result.Instance.Size/2,0) )- HRP.Position).Magnitude
time = distance/speed
-- you can use tween service to once the tween is completed check if they are still on the wall and just let go of the wall.

I would do a raycast like this

	local r = Ray.new(c.HumanoidRootPart.Position, c.HumanoidRootPart.CFrame.UpVector * -5)
	local Wall = workspace:FindPartOnRay(r, c)
if Wall then
-- stop sliding down
end
``

You can use this script

local humanoid = script.Parent:FindFirstChild(“Humanoid”)

humanoid.StateChanged:Connect(function(oldState, newState)
if newState == Enum.HumanoidStateType.Landed then
print(“Humanoid has landed!”)
– Do something here, like playing a sound or changing a property
end
end)