I need help with my wall climbing. It’s not constraining a character to a surface and it doesn’t constrain a character’s position. Here’s the part of the code I’ve been focusing on:
ClimbConnection = Runservice.Stepped:Connect(function()
local SurfaceInfoRay = workspace:Raycast(HRP.Position,HRP.CFrame.LookVector * 2,Params)
if SurfaceInfoRay then
local ConfirmationRay = workspace:Raycast(HRP.Position + Vector3.new(0,3,0), HRP.CFrame.LookVector * 2, Params)
if not ConfirmationRay then
ClimbConnection:Disconnect()
Dismount("WallEnded")
else
alignPosition.Position = SurfaceInfoRay.Position + (HRP.Position + Vector3.new((Right+Left)* ClimbSpeed,(Forward+Backward)* ClimbSpeed,0))
alignorientation.CFrame = CFrame.lookAt(HRP.Position, SurfaceInfoRay.Position - SurfaceInfoRay.Normal)
end
end
end)
This post is lacking basic information that we need to help you out. Does this part of the script even run? If it does, then we need to be able to see these specific variables to see what’s going on. Otherwise it’s the conditions that aren’t being met in the if then statement
The script runs an the character tries to position and orient itself. The conditions aren’t being met as those are to check if the character is still on a wall to trigger a dismount
Yeah your raycast looks very messy. It should only be one raycast happening. It either detects the condition you are looking for or not, using a “If not then” inside of a “if then” makes absolutely no sense.
One ray checks the position in front of the humanoid root part every second and the second verifies if the player is still on the wall by casting with an offset where the head would be to let a player know when the wall has ended and trigger the dismount function. Every frame I check to see if the head cast returns anything, if not then I’d play the mantle animation and tween the player to the top of the part.
There’s some stuff I have to do with that, but I’m not working on it until I get the player aligned to a surface like it’s supposed to be
When you say positioning, I’m assuming you mean the raycast that checks for the head right? It would be pretty difficult to perform a raycast to detect if the head is in an exact spot. Touched kind of feels better for something like this unless you have a reliable way of knowing that the head is always going to be in that position so that the raycast can never miss
I mean locking the character to one spot on a surface. It orients to the surface, but moves the player in a direction that doesn’t correspond to any of the input modifiers. It moves the character even when there isn’t any input.
The loop with the climb connection most definitely aligns with this. You are using align position to move the character. If you don’t want that then you’ll have to remove it from the loop
ClimbConnection = game:GetService("RunService").Stepped:Connect(function()
local SurfaceInfoRay = workspace:Raycast(HRP.Position, HRP.CFrame.LookVector * 2, Params)
if SurfaceInfoRay then
local ConfirmationRay = workspace:Raycast(HRP.Position + Vector3.new(0, 3, 0), HRP.CFrame.LookVector * 2, Params)
if ConfirmationRay then
local hitPosition = SurfaceInfoRay.Position
local hitNormal = SurfaceInfoRay.Normal
local hitPart = SurfaceInfoRay.Instance
print("Hit Part:", hitPart, "Position:", hitPosition, "Normal:", hitNormal)
else
ClimbConnection:Disconnect()
Dismount("WallEnded")
end
end
end)
I think I found the issue, the alignposition isn’t setting the position correctly and is instead setting the position diagonally like 1k studs away. I’ll report back once I’ve narrowed it down
Edit 1: I’ve narrowed it down to the logic that updates the alignposition based on direction value updates.
Alright, I figured it out. I was being stupid and made the alignposition try to reach the point of the raycast that was constantly above it, leading to a constant upward force.