Creating a 3rd Person Controller That Allows Wall Climb

I’ve spent most of my day trying to build a 3rd person character controller. It’s come together rather well, but I can’t seem to get beyond this block.

Expected Behavior:
User walks forward into an asset tagged “Wall” (the wall asset with box colliders framing various sections of the wall)
User begins to climb the wall at a slower speed than average movement.

Actual Behavior:
User walks into wall. User climbs over base of the wall and begins to scale first section (stone). User gets stuck under box collider representing the ledge 1/3 up the wall. (between stone and large flat section)

Environment:
Walls contain a base ledge, a ledge roughly 1/3 the way up the wall, a long flat surface, and another ledge on top. The ledges are actually more like baseboards and ceiling boards. I need to be able to climb over them as I climb up the wall.

You can view the code here:
https://codeshare.io/G64Nym

There is an image attached of the wall and it’s colliders. The little white capsule in the bottom right is the character prototype. It has a capsule collider around it that fits perfectly around the capsule itself.

What I need:

  • The character must be able to climb the wall, as well as run along the top of the ledges.
  • A better solution to climbing up the wall than translate (vector3.up) as it is causing problems with other functions.
  • To be able to jump off and away from the wall when the player hits space.
  • To be able to climb slowly as the distance the player will be able to climb will be controlled by stamina.

What I’ve Tried:

  • Adding a trigger quad that pushes the player away from the wall OnTriggerEnter. It was working before I switched from test movement (always forward) to manual control (hold w).
  • A sloped quad/plane. These seemed to work at just the right angle, but if I add more slopes or 3d assets to the wall, it fails. e.g., just the one slope will get me over the middle ledge, but if I add another to get me over the top ledge, the middle slope fails. I’m not sure why that’s happening.
  • I’ve looked into getting the location of the outer edge of the box collider on the middle ledge and moving the character to that transform.position, but it appears that that’s not an easy task to accomplish, if possible at all.

If you can point me towards a better solution for this, please do. I’ve scoured the internet today trying to find a solution or even a hint of how to do this, and I can’t seem to find anything that fits just what I need.

Is it time to rewrite this code in a more complex way, or can I save it?

3050052--228821--Capture.JPG

Could this potentially be the answer to your problems? It uses rigidbody rather than colliders but it could nonetheless work and you could adapt this code to work on only certain tagged walls and so on if you only want players to access certain sections of the game.

Sorry for the Java but I immediately thought of this sticky bomb tutorial when you mentioned this to me, the code should be the same for wall jumping, except, what would happen here, is you would press the spacebar or whatever you have as jump and then de-attach the player from the wall and have him attach again if he manages to hit a tagged wall you want him to be able to wall jump off.

This is at least how I would potentially get something in and I suppose you could even use this technique just for climbing ladders and so on.

I never did this but for the run and jump, I would try to always detect in a OnColliderStay the current normal of the collider.

To jump I would use this normal to set the jump direction.
To run I would try to use a Dot product to disable “use gravity” on his rigidbody.