Tilting character to surface. Lost in vector math. help please

I want to be able to make my character walk on the roof, walls and floor, I got it working up to 90 degrees but the trouble is as soon it gets steeper than that the character flips back the right way up so the head points to the walls and roof rather than the feet… any ideas?