GML Stuck Wall Hang/Ledge Grab

M

mojius

Guest
Hello, I'm a novice in GML and Game Maker but with a few tutorials I've managed to get pretty far.
I'm trying to make a platformer game where the character can jump in the air onto a wall by holding the arrow key in the direction of the wall. (only when he is in the air.) But this is what I'm trying to do and haven't been able to yet:
  • The character can only jump back onto the same wall after a small pause (for instance, jumping off the same wall while holding the same arrow key towards the wall, but instead of going a tiny bit higher, allowing a "cooldown" before the character can grab the wall again.
  • When the character grabs the wall, they have to either jump, press down on the arrow key, or press in the opposite direction of the wall.
At the moment, the character can't even grab the wall: When in the air and touching a wall their vertical and horizonal movement freezes independent of gravity like i want (basically, they "almost" hang on the wall for a split-second/frame) but then they fall back down to the ground.

Does anyone know how to do this? I'm using Shaun Spalding's revamped pixel-perfect platformer physics, and I'm trying to code this within the "step" action.

Sorry for the wall of text - I appreciate any help I can get on this
 
S

Sami

Guest
If your collision detection is pixel-perfect, are you checking collision with the ledge one pixel outside of your sprite (depending on which way the character is facing)? Your collision detection might just move you out of collision with the wall you want to hold on to.
 
M

mojius

Guest
If your collision detection is pixel-perfect, are you checking collision with the ledge one pixel outside of your sprite (depending on which way the character is facing)? Your collision detection might just move you out of collision with the wall you want to hold on to.
You're right on the money! Thanks for the help - I tried that - and gave the wall-climbing action itself a "state" so that normal collision was overrode for that action. Now I just need to figure out the timer action and get the sprite to function properly. When I grab onto a wall (which I can do now without pressing any buttons, yay!) if I hit jump, it just does the tiny-raise thing I mentioned. I also need to find out a way to press down on the arrow keys and let it turn the state off (should be easy.)
 
M

mojius

Guest
Okay, I'm making headway - the animation for grabbing onto the wall works seamlessly and if I'm holding the key in the direction, I will stay on. Now, three things -

1. How do I make sure if I let go of the arrow key, he stays on the wall? As in, how do I create a state he can either jump up or press left out of?
2. How would I make it so he can only grab the wall if his lower half is touching the wall?
 
Top