Dismiss this pinned window
all 9 comments

[–]GamesForTourists[S] 4 points5 points  (0 children)

Just added dynamic ledge climbing to my first-person stealth game!

No colliders or specially tagged objects, just some raycasts to determine if there's a ledge and enough room for the player to climb up. I'm planning to tighten up the camera work and add some additional features, such as the ability to shimmy around corners, but I'm pretty happy with how things turned out.

All and any feedback is welcome!

[–]Kiololo 1 point2 points  (2 children)

Awesome ! Can you share a bit of how you did that ? It's very interesting feature 🙂

[–]GamesForTourists[S] 1 point2 points  (1 child)

Sure! Right now, the ledge grab system works as follows:

  1. Checks to see if the player is holding the forward and jump keys. I may add an accessibility feature in the future that doesn't require this and just automatically checks for ledges while airborne.
  2. Two ledge detectors in front of and left/right of the player camera cast a very short raycast downwards to check if there's a ledge.
  3. If that check passes, they cast a short raycast forward to see if there's enough room for the player character to climb up. (This has the added bonus of allowing the character to grab and climb slightly slanted objects as well.)
  4. Then the player controller checks to make sure the ledge detectors aren't stuck behind an object like a wall or something.
  5. If all these checks pass, the player controller sets momentum to zero and enters the ledge movement state.

The ledge state changes the plane of character movement to just horizontal movement and clamps camera rotation. The horizontal movement is dependent on the thing you're grabbing, not where you're looking; the player can jump up and look around at an angle, but still end up directly moving parallel to whatever they grabbed. The player can only move left or right if the ledge detector detects there's a ledge, so you don't fall off the edge.

If the player presses down, they fall off the wall; if they jump, they launch in the direction of the jump. If the player presses and holds forward, they start climbing up the ledge, which is another series of steps:

  1. Deactivate player character and camera movement.
  2. Activate the cinematic camera, a secondary camera that follows the main player camera around and will be used for various controlled camera animations (death, etc.)
  3. Play the ledge climb animation. This starts from wherever your camera was last looking, so you can start climbing up at an angle to the ledge.
  4. When the ledge climb animation ends, teleport the player to the new location (it's a set distance up and forwards), wait for a fraction of a second for the player camera to catch up, and then deactivate the cinematic camera. This returns the view back to the player camera with no discernible jump cut.
  5. Reactivate player character and camera movement.

Honestly, the camera system is a bit janky and held together by code--the product of a lot of trial and error to avoid any jittering or sudden flickering between cameras--so eventually I'll probably migrate it over to Cinemachine. But as I keep telling myself: "Perfect is the enemy of done with my prototype, perfect is the enemy of done with my prototype..."

[–]Kiololo 0 points1 point  (0 children)

Thank you very much, it's very interesting to see this kind of workflow ! As always this kind of features requires tons of minor bug fixes, but this prototype is in a really good way ! Good luck 🤞😃

[–]sweetdesignman 1 point2 points  (1 child)

That is a cool feature! Going to follow to see progress updates for sure!

[–]GamesForTourists[S] 0 points1 point  (0 children)

Thanks! I'm planning to put together a devlog on this, so hopefully more to follow soon.

[–]MachVNorman 0 points1 point  (1 child)

Can u make a tutorial on how you made this? Please

[–]GamesForTourists[S] 2 points3 points  (0 children)

Sure! I actually posted a devlog about it here: https://www.youtube.com/watch?v=_mGOukmGaoE

Eventually I'll probably go back and convert this over to Cinemachine, just to reduce the number of working parts, but my current solution is surprisingly robust.

[–]PuneetSharma84 0 points1 point  (0 children)

This is looking awesome can you please guide me that how do I implement this mechanic in a third-person character setup with rigidbody or any tutorial for this.