Dynamic Ledge Grabbing

Heya folks,

I’ve been working for the past few weeks on a dynamic ledge grabbing system. The idea is to avoid having to place grab areas all around the scene and have it work right away with the scene geometry. The basic idea is pretty simple - I use a starting point around my character’s head and shoot a ray trace forward. If that trace hits anything, I shoot another trace a few centimeters (15 in my case) above it. If that trace doesn’t hit anything, or if what it hit is far enough away, then we have a ledge! If this sounds confusing, here’s a picture that might help:

This is the very basic idea. After I have this info, I need to do another trace from above to get the exact height of the ledge (as my 15cm distance will most likely overshoot) and with that I have my attach point. The normal direction of the first trace (flipped 180 degrees) is my character rotation. Currently the system works and has the following features:

  1. Fully dynamic ledge detection
  2. Curved ledges (both curving up-down as well as forward-backward)
  3. Steps (Ledge suddenly shifting up, down, forward or backward, think exposed bricks).
  4. Corner Rounding (The corner is detected but one needs a root-motion based “hop around the corner” animation for it to work properly)
  5. Height Check (Check if there’s enough room above and below me to shuffle in that direction)
  6. Can attach to movable objects (and move with them)

When I shuffle I do the checks offseted to the left or to the right depending on direction. There are a few more traces and checks to get all of those features working but it works pretty fast overall. As my character doesn’t have animations at this point it doesn’t really look presentable, but you can find a few screenshots here: http://imgur.com/a/MaafZ

I would gladly release the system but right now it’s coupled quite tightly with my game code. If there are people interested in it though I can explore how to make it portable.

Best regards,
Damir H.

EDIT:
Just for fun, here’s a somewhat old, non-cleaned up version of my TraceForLedge function:

Hi Damir,

I know this thread is nearly a year old but do you, by chance, still have this ledge system intact? It’s exactly what I am looking for - I started implementing my own system based on your outline but all of the special case handling seems daunting.

Thanks!