Just an example. Go and click see inside to see how it works!
I used @fireball123 's wall detection tutorial. If you're not sure if it works or not, or you have tried to but it didn't worked, take a look at the one I made!