hey yall. currently trying to figure out how to implement good wall detection for wall sliding/wall jumping in my game. i have code implemented but for some reason i can't get the character to just look at the surface of the wall...any idea what im doing wrong? attached is the video of what happens and the code that runs every frame.
local function updateWallDetection()
if controllerManager.ActiveController == airController then
local cameraLookVector = cameraLookVectorNoY()
local wallFindCast = workspace:Blockcast(rootPart.CFrame, characterSize, cameraLookVector * (characterSize.Z/2 + 0.1), raycastParams)
if wallFindCast then
disableMultipleInputContexts({airContext, climbContext})
enableInputContext(wallContext)
local wallNormal = wallFindCast.Normal
local finalWallCast = workspace:Blockcast(rootPart.CFrame, characterSize, -wallNormal * (characterSize.Z/2 + 0.1), raycastParams)
if finalWallCast then
isHuggingWall = true
moveAction:GetBinding("WASDBinding"):SetDirections({
Up = Enum.KeyCode.Unknown,
Down = Enum.KeyCode.Unknown
})
wallCastPart.Position = finalWallCast.Position
local lookPosition = finalWallCast.Position
local futureCFrame = CFrame.new(rootPart.Position, lookPosition)
character:PivotTo(futureCFrame)
print("[CharacterServiceClient] Wall detected.")
end
else
moveAction:GetBinding("WASDBinding"):SetDirections({
Up = Enum.KeyCode.W,
Down = Enum.KeyCode.S
})
disableInputContext(wallContext)
isHuggingWall = false
end
end
end