Hi I am making a game in 2d where cahracter can walk on any type of platform that comes in front of him.
what I am doing is casting a ray from the character and if it hit the wall I am giving the wall rotation to the character
but this logic fails if the wall formed is below the base .You can see the attached image to be clear
Apply a constant gravity in the current down direction. This way if you are always heading in your feet direction.
Have two raycasts at your feet casting front and back at a short distance but long enough to hit the walls.
The previous raycasts are used only if you have no collision with your feet.
Use the normal of the hit to rotate your character
Now the consequences of that: your guy is standing, it is going down and collides with the ground, nothing special. As you reach the wall to the right, nothing happens. If you jump, the raycast is called, it hits the wall if you are close enough (else nothing happens and you are going down). If it hits the wall, you get the hit.normal and rotate your guy accordingly. At this point you are horinzontal, and gravity is to the right and the jump should have got you far enough from the ground so that the casts are not hitting the ground. You will then naturlly be stuck to the wall by the fake gravity.
You will have to try and tweak until it suits your needs but that should get you started at least.