GameMaker Studio 2 - Super Simple Tile Collisions

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • Super Simple Tile Collisions in GameMaker Studio 2
    Tile collisions can be complex, but they can also be simple. Check out the 3 functions you need to make them begin working.
    My Exclusive Courses💻🎮:
    - Comment to be entered into a weekly drawing for my Beginner Course!
    - Beginner Course Here! www.letslearnt...
    - Bundle Course Package & More Here! www.letslearnt...
    Social:
    - Connect with me on Twitter @Aaron_LLTT: / aaron_lltt
    - Become a valued Patron and receive more exclusive perks @: / 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...

Комментарии • 63

  • @michaelcapone175
    @michaelcapone175 4 года назад +17

    I've always resisted the move to tilemap collisions (growing up on object collisions and all), but this video makes it look pretty easy. I think it's worth a shot. Thank you.

    • @hiiambarney4489
      @hiiambarney4489 3 года назад +1

      I mean... Why wouldn't you try and collide with tiles? Even Unity, being a 3d Engine, unlike Game maker, collides with 2d Tilesets efficiently.
      It's a shame that Game Maker doesn't provide an easier, more streamlined option for this, which is probably why the community said fuck this engine.

    • @Sim2322
      @Sim2322 3 года назад +1

      Well, a gane maker object has like 50 built-in variables, alarms, checks and stuff going on every step. Why would you need your walls to check for all those with every instance of platform you have? On the efficiency side, there's just no comparaison.
      Since 2.3, I almost pretty much just use 1 or 2 actual objects, the rest being structs. It does save a lot of power, try it.

  • @steventechno
    @steventechno 4 года назад +13

    This script looks a bit easier to follow. The other ones are going all hard on the math, which isn't a bad thing, but for idiots like me, it is. and what snipped I saw in the video didn't look too tough to dissect and learn from. I want to use Tile-based collisions on my next project in GMS 2.3 after I finish my 2.2.5 project, because my current method of using object collisions do feel quite sloppy.

  • @Likethisimage
    @Likethisimage 3 года назад +2

    It took a while to fix it up in a way for me to personally understand, but it worked out great in the end, thanks!

  • @hellasenpai
    @hellasenpai 4 года назад +1

    Thanks! I will for sure buy your course on my next paycheck.

  • @chrono581
    @chrono581 3 года назад +1

    Damn that makes collisions a lot more simple

  • @soulguardian6893
    @soulguardian6893 2 года назад

    so i tried to use your tile collision code for your left collision, but when use it somehow my game freezes, you know what the issue might be?

  • @kiravati
    @kiravati 2 года назад

    How would this work if you did this vertically?

  • @josephcampbell9697
    @josephcampbell9697 4 года назад +7

    Thanks! I like this short quick format. I also appreciate a video on tilemaps, we need more of these.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 года назад

      Congratulations Joseph! You've won the free beginner course giveaway! Please email me at aaron@letslearnthistogether.com to claim your coupon code 😄

  • @dr.dripremixes3116
    @dr.dripremixes3116 2 года назад

    In your project near the end of the video, how could you change the //Left Collision and //Right Collision to be used Vertically. I'm new

    • @koseidiamond
      @koseidiamond 2 года назад

      //I'm using this for the down collider
      if(tilemap_get_at_pixel(tiles, x, bbox_bottom + speedY) != 0)
      {
      y = round(y)
      while (tilemap_get_at_pixel(tiles, x, bbox_bottom) != 0)
      y -= 1
      while (tilemap_get_at_pixel(tiles, x, bbox_bottom) == 0)
      y += 1
      speedY = 0
      }

  • @randokaratajev2617
    @randokaratajev2617 2 года назад

    How can I make a passable platform out of tileset?

  • @abdullahismail9425
    @abdullahismail9425 Год назад

    I used the same code for the vertical collision and now my character won't jump anymore. Did you figure out a way to fix this?

    • @abdullahismail9425
      @abdullahismail9425 Год назад

      Ok i figured out the jumping issue but now the top collisions don't work. My character just clips through the platform and warps outside it. Can you show the code you used for vertical collisions in your example

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  Год назад

      I suggest you download the Windy Woods template from GameMaker, they have tile collision in there that works way better than what I’ve got.

  • @dannybroyles5393
    @dannybroyles5393 2 года назад

    Is it possible to do ramps/hills using the tile collisions?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  2 года назад

      I’m sure it is possible, although I’ve not done it personally.

    • @timothygottlieb2013
      @timothygottlieb2013 Год назад

      It is vary much possible it just is a pain in the butt. one way is to load all of the tile set in a room before hand have it iterate through it to determine what is actual tile and what is empty space. because by default it considers all of a tile even if parts of it are transparent. best way to do it is to have a collision tileset that is super simple that has all the curves slopes and what not you need store what is real space in some kind of matrix and reference that later

  • @alecacosta
    @alecacosta 4 года назад

    Is possible to edit the terrain using tiles? like moving a box or digging in sand

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  4 года назад +1

      Yeah. There’s so much you can do with tiles in the game it’s crazy.

  • @nadurr
    @nadurr 3 года назад

    how you can implement jumping with this code?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад +1

      I am working on that myself, as it was a little more complex than I thought.

  • @KorneeMoedt
    @KorneeMoedt Год назад

    for some reason my character won't jump anymore. any way to fix it?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  Год назад

      You might inside of the floor, triggering your collision code. Check that you’re not in a tile or floor

    • @KorneeMoedt
      @KorneeMoedt Год назад

      @@LetsLearnThisTogether alright

  • @teddyr254
    @teddyr254 2 года назад

    can you make one in dnd?

  • @SmogChad
    @SmogChad 3 года назад

    is the mouse a character

  • @BossAleks123
    @BossAleks123 3 года назад

    too complicated °^^

  • @HitcH55
    @HitcH55 Год назад +2

    I have no idea how to get jumping to work, as all jump tutorials reference an object to check for collissions on (like an obj_wall as an example). How do you implement jumping that also detects the collisions on the tilemap?

    • @АндрейБоденко
      @АндрейБоденко 7 месяцев назад +1

      if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0 and keyboard_check_pressed(vk_space)
      {
      VerticalSpeed = -PlayerJumpForce
      }
      or
      if tilemap_get_at_pixel(tiles,oPlayer.x,oPlayer.bbox_bottom-1) == 0
      {
      OnGround = 0
      } else {OnGround = 1}
      and then you're already doing a jump check. Is it really that difficult?

  • @anoymous5090
    @anoymous5090 3 года назад +1

    Hey do you know what I did wrong with this code? As of right now all it does is either not work or crash my game
    // Top Collisons
    if (tilemap_get_at_pixel(tiles, bbox_bottom + ySpeed, x) != 0) {
    y = round(y);
    while(tilemap_get_at_pixel(tiles, bbox_bottom, x) == 0) {
    y -= 1;
    }
    while(tilemap_get_at_pixel (tiles, bbox_bottom, x) != 0) {
    y += 1;
    }

    ySpeed = 0
    }

  • @robbob6143
    @robbob6143 2 года назад +1

    "layer_tilemap_get_id" only runs once at the creation of the object. How does "tilemap_get_at_pixel" use tiles as an argument if it is always the same element of a tile map?

    • @derekchang2957
      @derekchang2957 Год назад

      the tilemap_get_id is stored inside a variable which has the room tiles, aka tilemap. tilemap_get_at_pixel format is (tilemap, x, y) that checks what tile the point at x, y is touching on tilemap [tilemap]. if its 0, it means theres no tile at the point

  • @_bubblezzzzzz_
    @_bubblezzzzzz_ 2 года назад +1

    Awesome stuff, checking out your website!

  • @Sheep793
    @Sheep793 Год назад

    it didint work help

  • @PedroArthurMacielAlbuque-go3kj
    @PedroArthurMacielAlbuque-go3kj 11 месяцев назад +1

    THXXX broooooooo!

  • @yulaserio
    @yulaserio 3 года назад +1

    Thank you so much

  • @talkashie
    @talkashie 3 года назад +1

    Not working for me. My character goes into the tile then zips to the other side.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад +1

      That’s a common problem. It usually means a small typo in the while loop. Download my project and compare it to yours. You’ll find it there.

    • @talkashie
      @talkashie 3 года назад

      @@LetsLearnThisTogether I'm trying to collide with a specific tile, just not the whole tileset, so it's a little more complicated on my end. I'm about to just go back to object collisions because this just isn't working for me

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад +2

      Tile collisions are tough.. I plan on adding some more videos soon. Can you explain what you’re doing and why? I may make a video on it.

    • @talkashie
      @talkashie 3 года назад +1

      @@LetsLearnThisTogether I ended up getting some help designing a solution that works like position_meeting but for tiles, so I can just reuse my object collision code for the most part. Thank you though!! I appreciate the quick responses

    • @allendavis2821
      @allendavis2821 3 года назад

      @@LetsLearnThisTogether I know this is 3 months ago but I cannot find the link for downloading your project :(

  • @BazSupport
    @BazSupport 2 года назад

    Is there a pattern to how the tilesets are given their ids?

  • @timofeysamokhin9918
    @timofeysamokhin9918 4 года назад +7

    Can you make a complete video of the tutorial? Can not understand anything.

  • @doctorghost2900
    @doctorghost2900 2 года назад

    didnt work, pls help

  • @weebinit8011
    @weebinit8011 2 года назад

    do slopes work?

  • @dynoq
    @dynoq Год назад

    I'm struggling on figuring out how to detect the numbers it generates. Do you know how to help?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  Год назад

      I’m not totally sure, can you elaborate on the problem? You mean specifically on finding the number of the tile set you’re colliding with?

  • @jpixelart8472
    @jpixelart8472 3 года назад

    In place of "mouse", I should I put?
    I want to collide my obj_player with the tileset...

    • @steventechno
      @steventechno 2 года назад

      I know this is a necro post, but you ca try doing obj_player.x,obj_player.y

  • @cbacubiasmamarre5409
    @cbacubiasmamarre5409 2 года назад

    It gives me the error "create at line 4 cannot set a cobstant to a value" any help?

  • @joeplain3133
    @joeplain3133 3 года назад

    Hi :) Can I ask where did you get those super cute tiles? I tried to find them but couldn't

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад

      You know what, I'm having a hard time finding them, too. You can check out this link for some that are pretty similar. If I find the specific tiles, I'll definitely link them for you.
      opengameart.org/art-search?keys=platformer

    • @joeplain3133
      @joeplain3133 3 года назад

      @@LetsLearnThisTogether Thank you very much :) I checked there but maybe I missed them.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад

      There are some that are similar, but none exact.

  • @venelaka6298
    @venelaka6298 3 года назад

    How to destroy a tile in a specific location?

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  3 года назад

      I think this is what you want: docs2.yoyogames.com/index.html?page=source%2F_build%2Findex.html