• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Climbing Ledges

F

Freedom2Fight

Guest
Hello everyone.

I have been trying to make my character clamber up ledges for some time.

This is what I hope to achieve:



I cut the first few frames but she jumps and uses that momentum to climb. That is why she doesn't stick to the wall.

Er, right.

Now, I have managed to make my character hang on ledges...
...but I am finding it hard to write the climbing part.

So far I have managed to do this:



It has... issues. Its not how you say... precise? She briefly falls because she is too high.

How can I improve this to match what I hope to achieve?

I know I am missing few things. I need to know what those are. Maybe I can fix this before going to the Programming section.
 

Roderick

Member
Make your climbing sprite way bigger. Empty space all around, and put the point of origin in the center. Then line up her hands with the point of origin on every frame.

You will have to adjust her position when you switch from another sprite to this one, and back after, but that's easier that adjusting her position every frame while climbing.
 
F

Freedom2Fight

Guest
Thank you, Roderick for your answer. I do have some solutions for the sprite. I'll add yours to the list.

I am also concerned with how I made her climb up though. I need something with more precision.

How I did it was add a negative value to her y every time player_animate increases. Then when player_animate reaches 8 and above her x will also change depending on her direction.

However it did make her go too high. This caused her to fall briefly. And I don't like it.

However I thinking of something that will align the bottom of the mask (the green vertical bar) to the "top part" of the ledge of she is trying to climb. When that is done, slide the mask a couple of pixels to whichever direction she is facing.

Now I have tried translating what I said into code but as a novice I am unable to fully articulate my idea in to code. She would always end up floating to the skies, the stars and beyond.

I guess the question is what are the necessary variables, functions, and other stuff I should have to make that possible?

The bounding box? sprite_height? A while loop? place_meeting? position_meeting?
 

YanBG

Member
I think there is an easier way to do it, like making it only a visual change using a fixed sprite. The player's x and y would stay the same, just drawn on top of the cube, you can even draw a new cube to fit perfectly too. Then when you press another key the positions would change and start to walk etc.
 

Yal

🐧 *penguin noises*
GMC Elder
Yeah, the simplest way to make this is to make a climbing animation that stays in the same sprite and doesn't actually move the object around (I've used this approach in two games myself, so I can recommend it from experience). If you make the climbing sprite twice as tall and twice as wide as the normal sprite, it's the perfect size for ledges that are the same size as your protagonist, and very easy to align with before and after the animation.
 
F

Freedom2Fight

Guest
Everyone seems to be unanimous with the solution presented.

I've tried this before but I had some things bugging me so I didn't see it through.

Since the player object doesn't move, my camera object won't either.

And since the both objects doesn't move, I'd have to teleport the objects to the top of each ledge. Meaning I'd have to find the x,y of the top each climable ledge? I suppose I could do it before the climbing animation starts?

What if I wanted enemies to be able to hurt while climbing? Would that require a hitbox-like object to follow the sprite? Wouldn't that be the same as getting the player object to move?
 

Yal

🐧 *penguin noises*
GMC Elder
One idea to solve the camera issue is to move the object actually responsible for the camera (e.g. the player) smoothly between start and end point - linear interpolation would be just enough, making it invisible and perhaps intangible and moving in a straight line from start to end during the duration of the animation, while the animation is either just drawn, or handled by a separate object (depending on what approach you prefer). For enemies, you'd not make them intangible during the duration of this, but you'd make them ignore their normal terrain collisions until they've climbed up the ledge, so you can hit them but they won't get stuck on the ledges or things like that.

To find ledge coordinates, you'd just do this:
  1. Find a point inside the ledge solid object. This should be fairly simple.
  2. Move up until you find a point that's not covered by a solid object. That's the top of the ledge.
  3. From the solid point in (1), move towards the climber (right if the climber is climbing to the left and vice versa) until you find a point not covered by a solid object. That's the horizontal edge of the ledge.
 
F

Freedom2Fight

Guest
Thank you everyone for your answers. I greatly appreciate it.

I will try to use all the information given here to come up with a solution.

However if there is someone else reading this thread that has accomplished or tried to execute ledge climbing in the manner I am trying to achieve - please post any useful information here.
 
R

Rukola

Guest
@Freedom2Fight, I would follow up Yal's advice. She knows her stuff. About the separate camera. Apart from this incident, what about potential cutscenes etc. Having a obj_camera seems like the natural way of how you should want to design your game.

To get you started:

Code:
//I'm assuming you're using the room follow intance function to follow your main character!
obj_camera:

end step event:
x = obj_ledgegirl.x;
y = obj_ledgegirl.y;
message me if you need some pointers for coding this ;)
 
Last edited by a moderator:
F

Freedom2Fight

Guest
Thank you Rukola for your answer and offer to help, however my camera object is already up and running.

Now then.

With everything I have gathered here and with the people that I have contacted behind the scenes. I will now present my solution.

The gif below demonstrates what I am going to do.

1. The animation shall be handled by a separate object called the "static object". That is however a working name for it.
2. The player object itself here [will become invisible. Well it isn't now but you know... Ahem. When in the climbing status, it shall try to move horizontally to whichever direction it is facing but if there is a wall/solid object, it will instead move up until there isn't and only then shall it move a couple o' pixels to the left or right. (This is done mostly because of how my game works)
3. Once the animation is over and if the player object is over the obstacle and aligned (hopefully - if it isn't aligned that will make her jitter) with the location of the last frame of the climbing animation - resume normal operations.






With this - it is my hope that my camera object will follow the player object and it will make checking for enemy and projectile collisions easier.

If anyone has any corrections, additions, or objections please let me know. I really need it.

Thank you in advance.
 

Yal

🐧 *penguin noises*
GMC Elder
I mean, the approach I posted three years ago still works. Also, the OP literally posted their solution in the post preceeding yours, @PRIZRAK88 , with an animated GIF and all:
 
Top