Wall Climbing issue [video]

Hello, when I try to go left/right on the wall while in the air, my character immediately falls to the ground. I don’t have this problem when I try to go up/down the wall. I just can’t figure out what the problem is and how to fix it. Below are the lines of code for the climbing system (There’s an attachment, and the player’s CFrame is the attachment’s WorldCFrame, and I move the attachment when I want to move. I do this because it’s handy for holding the char onto a moving/rotating wall, with a AlignOrientation to rotate the character to the wall).
Any help suggestion are appreciated. Thank you.

The important value is probably the ‘nextCframe’ value (you can see it in the script)

while CanClimb do
	local currentPosition = char.PrimaryPart.Position
	local RayCastCheck = workspace:Raycast(RayCentre.Position, char.PrimaryPart.CFrame.LookVector * 4, raycastParams)
	if RayCastCheck then
		local RayPo = RayCastCheck.Position
		local MoveDirection = ControlModule:GetMoveVector()	
		local nextCFrame = CFrame.new()

		AlignOrientation.CFrame = CFrame.new(currentPosition + RayCastCheck.Normal,currentPosition)
		animationClimb:AdjustSpeed(MoveDirection.Z ~= 0 and -MoveDirection.Z or math.abs(MoveDirection.X))
		if MoveDirection.X ~= 0 then
			nextCFrame = CFrame.new(RayPo,RayPo+RayCastCheck.Normal) * CFrame.new(-MoveDirection.X/5, MoveDirection.Z/5,0)
		else			
			nextCFrame = Attachment.WorldCFrame * CFrame.new(0,-MoveDirection.Z/5,0)
		end
		Attachment.WorldCFrame = nextCFrame
		char.PrimaryPart.CFrame = char.PrimaryPart.CFrame.Rotation * CFrame.new(0,0,1) + Attachment.WorldPosition 
	end			
	task.wait()
end

Thanks again

5 Likes

with workspace.Gravity = 0 it is better but still very unstable and not good

Where is RayCentre located? And also what is Attachment parented to?

1 Like

The Raycentre is located below the HumanoidRootPart, the attachment is parented to the wall

1 Like

I have a suspicion that it has to do with the axis of rotation of the wall. Moving vertically is a long the axis, so no problem, but moving left and right will slightly clip the player into or away from the wall. Try changing the rotation axis around and see what happens.

So my guess is that while your character sticking on a wall (while not touching the ground), the gravity will keep increasing the down force of your character.

While the MoveDirection.X == 0, Attachment’s WorldCFrame will be itself but slightly higher or lower and
since it’s parented to the wall (which is anchored), it will be unaffected by gravity

While the MoveDirection.X ~= 0, Attachment’s WorldCFrame will have the position of the RayPo, which is shot from RayCentre, which is parented to HumanoidRootPart, which is affected by gravity
→ Attachment’s WorldCFrame will be affected by gravity, and thus, result in you falling to the bottom the moment you move left or right due to the accumulated down force from gravity.

My solution is to set char.PrimaryPart.Anchored = true or constantly setting char.PrimaryPart.AssemblyLinearVelocity = Vector3.zero while the player is sticking on the wall.

Again, that’s just my guess, there’s a good chance that it’s wrong.

1 Like

I know that if the HRP is anchored, i don’t have this issue, but the alignOrientation physics is stopped. I’m nowtrying to find a way to rotate the LowerTorso Root C0 to always face the part, because when it’s not facing the mechanic is stopped

Yep the solution seem to anchore the HRP

Just use CFrame.lookAt, set the first parameter to your character’s position and the second to character’s position - the ray’s normal

1 Like

Here we go, thank you very much for your help !

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