Ladders/climbing walls?

Blitz3D Forums/Blitz3D Beginners Area/Ladders/climbing walls?

Robey(Posted 2010) [#1]
Hi, I'm trying to think of the easiest and most efficient way to program a ladder/climbing wall for a first person shooter. Right now I've set up a collision between the player and the ladder so that while the player is moving forward and colliding with the ladder, they move upwards.

I've basically made a variable "Climb_on" that becomes true when the player is colliding with the ladder, and becomes false when the player is not colliding with the ladder. The player moves upwards when this switch is on and the player is moving forward. However this has lead to a problem,

If the player stops moving mid-climb, "climb_on" becomes false (as the player is no longer 'colliding') and so the player falls.

What is intended is that the player "sticks" to the ladder/climbing wall. How would I go about doing this?


_PJ_(Posted 2010) [#2]
Not sure how others have approached this, but i WOULD DO EITHER:

1) Set a vcariable to act as a switch, similar to the Climb_On idea you have, but is activated when the player is first in contact with the ladder, but ONLY deactivated once the player purposefully 'jumps off' or reaches a 'Pivot point' at the top of each climbable ladder.
This way, the player is somewhat "stuck" to the ladder, so perhaps sidewards movement (i.e. strafing) is restricted if the variable is set, and the player cannot leave the ladder without jumpoing or reaching the top.
This introduces a possible issue with climbing down, though, so perhpas the first collision would also need to allow the player to automatically climb 1 rung, then you are free to check for collisions with the ground to deactivate the switch.

Another idea maybe to build your ladders whether the actual objects or hidden surfaces in 'bits', so that there are a number of these parts each about 3/4 the 'player height' all the way to the top of the actual ladder. This way, the player should always be in contact with part of the ladder

Actually now Ive just said all that, it's clear that it's certainly easier said than done, but of course, most FPS type games seem to handle ladder-climbing with little diffioculty so presumably there is a fairly straightforward way to go about it.
Personally, I'm still in favour (honestly not egotistically) with the first option, since the condition of the 'switch' can be used to do all sorts of other stuff too, such as, making aiming harder for example.


Shambler(Posted 2010) [#3]
I did ladders by placing an invisible quad just above the floor underneath the ladder.

This was detected by a downwards linepick and the player was then put into ladder climbing mode i.e. if they look up they go up, if they look down they go down. If they stray outside of the quad they come out of ladder climbing mode and into fall mode.

The quad was part of a type that also held a field stating the height of the ladder so the progeam would know when the player has reached the top.


_PJ_(Posted 2010) [#4]
That's a great idea :)


Robey(Posted 2010) [#5]
Alrighty, This is what I've come up with so far. When I touch the ladder, climbing mode becomes true. This disables X and Z movements meaning the player can only travel up and down the ladder, and to prevent the falling I reduced the gravity to zero temporarily. Another key is pressed to be released from the ladder and return gravity to normal.

Now the only thing left is getting off at the top of the ladder.


Rob the Great(Posted 2010) [#6]
To solve this problem with ladders in my game, I made two pivots, one positioned at the top of the ladder, and one positioned at the bottom. If the character, or the camera, or whatever it is that you're using for the player gets within a certain distance of those pivots, you can position the player over time away from the ladder like they were climbing off and disable any variables which would hold the character to the ladder, as well as turn the gravity variable back to normal.

I'm sure there's a better way to do it, but it seems to work well enough for my game.


Rob the Great(Posted 2010) [#7]
Another note, I don't have my game in front of me, but I do remember that this caused a lot of glitches when the player first walked onto the ladder, because they were already close to those pivots.

To overcome this, I made a quick loop when they first entered the ladder and forced the character to move up or down the ladder, far enough away from the top and bottom pivots that it wouldn't accidentally push the character off when he first got on.

I'm hoping this makes sense. Let me know if I need to explain the process a little more.


_PJ_(Posted 2010) [#8]
To overcome this, I made a quick loop when they first entered the ladder and forced the character to move up or down the ladder, far enough away from the top and bottom pivots that it wouldn't accidentally push the character off when he first got on.



sounds like what I was getting at here:

perhpas the first collision would also need to allow the player to automatically climb 1 rung, then you are free to check for collisions with the ground to deactivate the switch.



Hope it's all working okay, sounds pretty good so far.
Have you sorted out the getting on/off yet?

It may be an idea, too, if the player does 'Jump off' the ladder halfway up, that they jump far enough aay to prevent them landing back at the point where they'll just collide (Climb onto) the ladder again!


Robey(Posted 2010) [#9]
Yep it's pretty much sorted out... a little primitively though. I placed an invisible cube above the top of the ladder, so when the player touches it on the way up, they are boosted forward onto the platform and gravity is set back to normal.

Thanks a lot for the help! :D


*(Posted 2010) [#10]
In Hunted I done it the way Shambler suggested it worked out fine and allows the player to jump off when they want rather than being stuck on the ladder.