Stuck on walls or sliding on top dilemma

I'm making a 2.5D platformer game. I earlier had problem with my character getting stuck on walls when holding the forward button. I solved this problem by adding a physics material with zero friction to my colliders on the wall. So now when hitting a wall the character slides down, which is correct.

My walls consits of 1 unit cubes tiled together, and box colliders are generated and merged at runtime.

Now I've created a ladder and by pressing a button the player will rotate 180 degrees, and I also add some force along the y- and z-axis:

var force = -transform.forward + Vector3.up;
force.y *= JumpOffForceY;
force.z *= JumpOffForceZ;
_rigidBody.AddForce(force, ForceMode.Impulse);


Now when the player lands on the top of the wall, which has the same box collider, and physics material, the player slides very jerky for a long time before coming to a halt.

I understand why this happens, I've been trying to find a solution. One solution I'm thinking of is to change my algorithm that creates the box colliders and divide them so there is one box collider on the top with higher friction, and one for the walls with zero friction. Before I delve into that, is that a good solution? Or is there any other way?

Have a nice day!

2 Answers

I faced a similar problem a long time ago, and found that for me the easiest solution was to add a second collider, which was thin, but acted as a surface for walls/rooftops. I then made a prefab which I could scale around my visual object. Maybe that helps?

Unity had a Character Controller for this exact reason. It works very well for 3D, and should translate just fine to 2.5D.