Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my game, I'd like my character to be able to grab and hold onto ledges, and to be able to pull themselves up if there's room to do so.

How do I detect if there's a ledge, and if the character has enough space to climb up?

share|improve this question
    
This question was created as a canon version of two earlier questions. See the meta discussion here. –  Jonathan Hobbs Oct 20 '12 at 0:34
1  
1  
Also, linking the questions talked about in meta: gamedev.stackexchange.com/questions/38066/… and gamedev.stackexchange.com/questions/15491/… –  Byte56 Oct 20 '12 at 0:54

1 Answer 1

up vote 12 down vote accepted

The video for Overgrowth Alpha 132 shows how they implemented ledge climbing.

Their method should work in any engine, even 2D engines where you'd use a rectangle and circle instead of a cylinder and sphere.

Their ledge detection involves two parts:

Wall detection (using the sphere)

The game checks if the player's currently colliding with a wall. If there's a wall, there might be ledges the player can grab onto. The second part takes over to analyse the ledges.

Ledge detection (using the cylinder)

If the player's contacting a wall, a cylinder is swept downwards from a certain distance above the player's position until it touches a ledge. This determines three things:

  • Whether a ledge exists above the player
  • The ledge's height
  • Whether there is room for the player to climb up onto the ledge, considering the cylinder occupies the same horizontal space as the player.
share|improve this answer
    
Amazing method, and fantastic example +1 –  Bugster Oct 20 '12 at 12:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.