I’ve never coded this kind of thing, but you need to be able to cope with the player landing sideways and so on.
I would say at every move, you might need to do a capsule trace ( in 5 directions ) to see where the next most likely surface is.
In this case, a sideways trace would find the floor, and then you can align the player, using the same method you just used for the wall