1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Climbing Ledges

Discussion in 'Game Design, Development And Publishing' started by Freedom2Fight, Nov 11, 2016.

  1. Freedom2Fight

    Freedom2Fight Member

    Joined:
    Jun 25, 2016
    Posts:
    94
    Hello everyone.

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

    This is what I hope to achieve:

    [​IMG]

    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:

    [​IMG]

    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.
     
  2. Roderick

    Roderick Member

    Joined:
    Jun 22, 2016
    Posts:
    580
    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.
     
  3. Freedom2Fight

    Freedom2Fight Member

    Joined:
    Jun 25, 2016
    Posts:
    94
    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?
     
  4. YanBG

    YanBG Member

    Joined:
    Jun 25, 2016
    Posts:
    576
    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.
     
  5. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,846
    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.
     
    Freedom2Fight and Rukola like this.
  6. Freedom2Fight

    Freedom2Fight Member

    Joined:
    Jun 25, 2016
    Posts:
    94
    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?
     
    SnotWaffle Studios likes this.
  7. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,846
    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.
     
    Rukola likes this.
  8. Freedom2Fight

    Freedom2Fight Member

    Joined:
    Jun 25, 2016
    Posts:
    94
    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.
     
  9. Rukola

    Rukola Member

    Joined:
    Jun 20, 2016
    Posts:
    72
    @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: Nov 23, 2016
    Freedom2Fight likes this.
  10. Freedom2Fight

    Freedom2Fight Member

    Joined:
    Jun 25, 2016
    Posts:
    94
    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.




    [​IMG]

    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.
     
    Alexx likes this.
  11. PRIZRAK88

    PRIZRAK88 Member

    Joined:
    Sep 26, 2019
    Posts:
    1
    Can you post your decision? I'm making ledges now.
     
    SnotWaffle Studios likes this.
  12. SnotWaffle Studios

    SnotWaffle Studios Member

    Joined:
    Jun 21, 2016
    Posts:
    288
    Everyone's necro-bumping today lmao.
     
    sitebender likes this.
  13. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,846
    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:
    [​IMG]
     
    SnotWaffle Studios likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice