[GameMaker Studio 2] - Perfect Top Down, Platformer, RPG Collisions

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Getting stuck is no fun. Getting stuck in a wall in a video game is just the worst, so let's make sure that doesn't happen. Whether you're creating a platformer, RPG, top down shooter, or any other kind of game, if you've got moving objects, you need to control how they collide. I'll show you the best way to do that, and explain exactly how it works.
    Finished Project: drive.google.c...
    Social:
    - Connect with me on Twitter @Aaron_LLTT: / aaron_lltt
    - Become a valued Patron and receive more exclusive content @: / letslearnthistogether
    - Wanna hear from other developers in the industry? Head on over to my podcast, DevTalk, to listen to engaging conversations I have with various successful developers: devtalk.buzzsp...
    My Exclusive Courses💻🎮:
    - Bundle Course Package & More Here! www.letslearnt...
    Music courtesy of OC Remix.

КОМЕНТАРІ • 19

  • @sohomsahaun
    @sohomsahaun 3 роки тому +28

    Hey, the collision logic here is a bit wrong.
    The order currently looks like this:
    1. Check collision along x
    2. Check collision along y
    3. Move along x
    4. Move along y
    This can result in getting stuck when moving diagonally.
    Correct order should be:
    1. Check collision along x
    2. Move along x
    3. Check collision along y
    4. Move along y

    • @Camdavideogameaddict
      @Camdavideogameaddict 2 роки тому +1

      thank you so much!! you absolute legend!! I majorly appreciate it :D

  • @steventechno
    @steventechno 4 роки тому +1

    I really need to practice this more. I found this method on Shawn Spaulding's Platformer guide, I redid it entirely from memory one day, total success, then tried again the following day to no avail. just couldn't replicate it again for some reason. but I see it's the same system. I feel this method is far superior to place_free since we can completely forgo using the Black Box "Solid" property, and feels smoother while at it.

  • @interference2449
    @interference2449 4 роки тому +2

    This collision code is great! Btw, is it possible you can make a video about using a "z axis" in 2D, so the player can jump and be on top of platforms (using this system)? That'd be great!
    Can't wait for more.

  • @whatthedraw
    @whatthedraw 2 роки тому

    I dont know why but instead of writting :
    if (place_meeting (x + hMove, y, oWall))
    {
    while (!place_meeting (x +sign(hMove), y, oWall))
    {
    x += sign(hMove);
    hMove = 0;
    }
    }
    And putting the "hMove" in the "while", putting it in the if like this :
    if (place_meeting (x + hMove, y, oWall))
    {
    while (!place_meeting (x +sign(hMove), y, oWall))
    {
    x += sign(hMove);
    }
    hMove = 0;
    }
    solves the problem, in the first example I would get stuck against the wall and couldn't move anymore.
    Hope this helps to anyone who has the same problem!

  • @potato_dev6431
    @potato_dev6431 4 роки тому +6

    Thanks now I can sleep

  • @paracitoparatiscidav-rus6053
    @paracitoparatiscidav-rus6053 3 роки тому +1

    Gracias me sirvió.

  • @pekediablo150
    @pekediablo150 3 роки тому +2

    This code doenst work on my project. Wtf should i do more????

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 роки тому

      What exactly isn't working? Are you getting an error message? I can't help without more info.

  • @sk7811
    @sk7811 5 років тому

    Thanks. :D

  • @zakthedragonslayer449
    @zakthedragonslayer449 4 роки тому +1

    How would I make it so I dont get stuck when another collision is meeting with another collision (example enemy and player collide)

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 роки тому

      The same system should work for you. You just add in a check for them as well, usually with a parent system so you're not checking every single enemy.

    • @zakthedragonslayer449
      @zakthedragonslayer449 4 роки тому +1

      @@LetsLearnThisTogether im using the system. When both me and the enemy run into eachother i get stuck kinda i have to move a certain way to get out

  • @squishypowers
    @squishypowers 2 роки тому

    Sorry if this is a dumb question, but instead of moving 1 pixel at a time, why not just move the difference between the player and the solid (which we know is less than the regular move speed)?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 роки тому +1

      That’s a great question. The goal is to move that distance. But we don’t know what it is, and it could be different every time we run into a solid, so we have to do a loop to find where it is and then stop.
      There might be some other solutions which grab the sprite, figure out the bounding box and the side we’re approaching, but I think that may be even more complex. Might be worth trying out though.

    • @squishypowers
      @squishypowers 2 роки тому +1

      @@LetsLearnThisTogether I appreciate the response!

  • @scarm_rune
    @scarm_rune 2 роки тому

    quick question is this safe with precise masking objects?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 роки тому

      It can be, but it can also cause an issue if you’re changing the sprite near a wall, as it could get caught in there if it’s not symmetrical.

  • @mitsuck7881
    @mitsuck7881 5 років тому

    love u