Wall climbing system like in Deepwoken

So I’m making a game with mechanics similar to Deepwoken and I’m stuck on the wall climbing system. I’ve done the part where you climb up the wall, but there’s still a part where you can hang on the edge.

I tried to make it so that when a player climbs the wall, parts are created on the edges of wall, and then player attached to them, but it was too complicated and would put a lot of load on the server when multiple players were climbing, since everything is handled on the server-side script.

I tried to find some examples, but everything I found didn’t work the way I needed it to. So, any ideas?

5 Likes

I would suggest handling movement like climbing on the client because the movement is smoother. You’ll have to create an antiexploit like using a server event to check or even manage the cooldown.

As for the actual question at hand, you could use Raycasts on the HumanoidRootPart’s LookVector to see if you’re near a ledge if you hit space. The goal is to have two raycasts going straight ahead, and if one ray (let’s say this ray is at neck or eye level) scans the object the player is trying to climb, and the other ray (positioned a little higher than the first ray) either doesn’t scan anything or scans a different part, then you can ledgehang!

Here’s some sample code I’m working with right now myself:

uis.InputBegan:Connect(function(input, check)
	if check == false then
		if input.KeyCode == Enum.KeyCode.Space then

			local ray1Origin = char.HumanoidRootPart.Position + Vector3.new(0, -2, 0)
			local ray1Location = char.HumanoidRootPart.CFrame.LookVector
			local ray1Return = workspace:Raycast(ray1Origin, ray1Location)
			
			local ray2Origin = char.HumanoidRootPart.Position + Vector3.new(0, 2, 0)
			local ray2Location = char.HumanoidRootPart.CFrame.LookVector
			local ray2Return = workspace:Raycast(ray2Origin, ray2Location)
			
			if ray1Return then
				if ray1Return.Distance < latchDistance then --latchDistance is a variable I have to manage the distance I want a player to be able to climb from
					if (not ray2Return or ray2Return.Instance ~= ray1Return.Instance) and ray1Return.Instance:IsDescendantOf(char) == false and vaultDebounce == false then
						vaultFunction(ray1Return.Instance) --This is where you would want to ledgehang. I'm only using vaulting
					elseif (ray2Return and ray2Return.Instance == ray1Return.Instance) and hum.FloorMaterial == Enum.Material.Air and climbDebounce == false then
						climbFunction()
					end
				end
			end
		end
	end
end)

Hope this helps!

6 Likes

Thank you! Your idea with raycasts worked!
I was using a single raycast to detect the wall, but didn’t think that I can use two to detect the ledge.

I didn’t check if it’s the same part, because a wall can consist of several. So if, for example, the ledge is like on the pic. and has enough size that the upper raycast will not see the wall behind then player will be able to grab on. So the player will not grab on a small ledge “with his fingers”.
Ledge

Regarding smooth movement, I’m using velocity things for climbing so i don’t need to handle it on the client.

2 Likes

Try firing the ledge check from above & in front of the Character’s HRP with a height of what ever maximum climb height distance you want to validate the ledge hang or climb.

1 Like

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