GameMaker Studio 2 - Super Simple Tile Collisions

Поділитися
Вставка
  • Опубліковано 16 сер 2020
  • 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.letslearnthistogether.com...
    - Bundle Course Package & More Here! www.letslearnthistogether.com...
    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.buzzsprout.com/

КОМЕНТАРІ • 66

  • @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.

  • @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  3 роки тому

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

  • @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!

  • @steventechno
    @steventechno 3 роки тому +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.

  • @hellasenpai
    @hellasenpai 3 роки тому +1

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

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

    Awesome stuff, checking out your website!

  • @yulaserio
    @yulaserio 3 роки тому +1

    Thank you so much

  • @chrono581
    @chrono581 3 роки тому +1

    Damn that makes collisions a lot more simple

  • @PedroArthurMacielAlbuque-go3kj
    @PedroArthurMacielAlbuque-go3kj 9 місяців тому +1

    THXXX broooooooo!

  • @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?

    • @user-bi6xv6pr7k
      @user-bi6xv6pr7k 5 місяців тому +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?

  • @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?

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

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

  • @vitaly.petkevich
    @vitaly.petkevich Рік тому

    There is a bug: when you add new tiles, if an instance of the object with the tile map code exists in the room, the changes won't apply. You have to remove the object, update tiles, then bring the object back to the room. Also, multiple instances of the same tile, for example yellow tiles, have the same id - I'm not sure if this is meant to be so.

  • @anoymous5090
    @anoymous5090 2 роки тому +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
    }

  • @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
      }

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

    How would this work if you did this vertically?

  • @keagangrahamcallis7857
    @keagangrahamcallis7857 Рік тому

    I know it's an old video, but I have a question.
    Is it possible to detect collision with certain regions of a tile? Like if you want to detect collision with only the top half of a tile for instance.

    • @LetsLearnThisTogether
      @LetsLearnThisTogether  Рік тому

      Yeah. In essence, tile collision is checking all four sides and returning if you’re touching any of them. Go find a more in depth video or project with tile collisions and you can pull out specific sections like the top collision only.

  • @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.

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

    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

  • @robbob6143
    @robbob6143 Рік тому +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

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

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

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

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

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

    do slopes work?

  • @randokaratajev2617
    @randokaratajev2617 Рік тому

    How can I make a passable platform out of tileset?

  • @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

  • @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?

  • @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.

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

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

  • @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.

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

    can you make one in dnd?

  • @timofeysamokhin9918
    @timofeysamokhin9918 3 роки тому +7

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

  • @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

  • @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

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

    is the mouse a character

  • @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 :(

  • @Sheep793
    @Sheep793 Рік тому

    it didint work help

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

    didnt work, pls help

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

    too complicated °^^