I came up with a really easy way to script climbing a ladder in Game Engine. It basically just involves colliding with the ladder (which toggles a "Climbable" boolean) and then when you hold up or down to ascend/descend the ladder it temporarily sets Gravity to 0 (bge.constraints.getCharacter(obj).gravity = 0) so that the player isn't pulled downwards by gravity while they're clinging to the ladder. From there, I was smart enough to make it so if you press a side direction and aren't touching the ladder anymore there's an "Inverted" Collision with the ladder that makes it so if you aren't touching a ladder the Climbable boolean is always False and gravity immediately returns to normal (29.399999618530273, by default). All works properly as intended.
I have a problem though. If I jump onto the ladder or if I simply fall off of a platform onto the ladder and try to climb, it won't work as intended. If my character is jumping upwards to a ladder and I hold up to climb, then he will fly upwards like a rocket (on account of the zero gravity) and if I try to climb up a ladder while actively falling. The drag of falling will keep pulling my character downwards as he tries to climb and the drag continues until he collides with the floor (zero gravity doesn't negate downward force for some reason)
I need some way to "turn off" the falling behavior of a character and the upward motion of a jump on-the-fly so that my ladder scripting works properly. I can't figure out how to get them to stop. If anybody knows some line of code I could use to get him to stop, I would greatly appreciate it.
bge.constraints.getCharacter(obj).onGround is a "read only" boolean, so I can't use that to trick the game into thinking I've landed on ground. I've tried.
I am using Character Physics for my player character.