I want to make my character cling to walls when they fall, but do not know where to start

You probably played SpeedRun4, and I am making a fangame. However, As you may notice, In SpeedRun4 you can grab onto walls to save your life from a tragic fall! However, I have had no idea where to start, even after looking at thousands (exaggerated! wowie!) of posts on the forums…
Can anybody help me?

I have also 0 knowledge on this, but what I would start from, is check if player is falling, if true, then wait for user to for example click or press E to grab on to wall. When UserInputService receives input, check using sphere raycast for nearby walls, if true then play grab animation and stop freefalling.
This should be good starting point, I would give example but I’m in a hurry, so I’ll leave it here for now.

If questions or need help, just reply.

Put this LocalScript in StarterCharacterScripts:

local RunService = game:GetService("RunService")

local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")

local Attachment = Instance.new("Attachment")
Attachment.Parent = RootPart

local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.Attachment0 = Attachment
LinearVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
LinearVelocity.MaxAxesForce = Vector3.new(0, 10000, 0)
LinearVelocity.VectorVelocity = Vector3.new(0, 0, 0)
LinearVelocity.Enabled = false
LinearVelocity.Parent = RootPart

local CastParams = RaycastParams.new()
CastParams.FilterType = Enum.RaycastFilterType.Exclude
CastParams.FilterDescendantsInstances = {Character}

RunService.RenderStepped:Connect(function()
	if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
		if Humanoid.MoveDirection.Magnitude > 0 then
			local PartInFront = workspace:Raycast(RootPart.Position, RootPart.CFrame.LookVector * 2, CastParams)
			
			if PartInFront then
				LinearVelocity.Enabled = true
			else
				LinearVelocity.Enabled = false
			end
		else
			LinearVelocity.Enabled = false
		end
	else
		LinearVelocity.Enabled = false
	end
end)
1 Like

Wouldnt a ropeconstraint be better

Use raycasts to detect if they’re touching a wall, and then, increase the Humanoid’s slopeAngle (or smth like that), and create an Instance that can make them cling (BodyForce, LinearCostraints, WeldConstraints)

no cause then u cant move off the wall

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