Hello developers, I have just made a way to detect if the player is on a slope using raycasting, However, I now want to make a way to check if the player is moving up or down the slope. The problem with this is when the player is on a slope it will print out the same result no matter which way the player is moving.
Video of this and the result:
script:
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
run.RenderStepped:Connect(function()
local rayResult = workspace:Raycast(hrp.CFrame.Position, -hrp.CFrame.UpVector * 5, rayParams)
if rayResult then
print(rayResult.Normal.Y)
end
end)
If there is a method to checking if the player is going up or down a slope or if there is a way better method of achieving this please let me know.