Easy Tilemaps and Dynamic Auto Tiling - Unity 2D

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • In this video we'll create a tilemap, add a collider (so we can use it as platforms or walls) and also look at creating dynamic tilemaps using Auto Tiling and Tile Rules!
    By implementing tile rules, you can paint on your scene and it'll automatically place the correct sprites depending on the other sprites around it - it's really cool!
    On my Patreon you can get the package which includes this Tilemap and Rule Tile - so you don't have to set it up yourself:
    / gamecodelibrary
    (My Patreon also includes all past and future code, packages and assets used on my channel!)
    www.buymeacoffee.com/gamecode...
    Spritesheet: rottingpixels.itch.io/nature-...
    Easy 2D Platformer: • Platformer Player Move...
    0:00 - Intro
    0:14 - Package Setup
    0:30 - Sprite Setup
    1:02 - Tile Palette Setup
    1:33 - Grid Tilemap + Tilemap Working!
    1:58 - Auto Tiling!
    2:07 - Rule Tile Setup
    2:37 - Rule Tile Explanation
    3:30 - Rule Tile into Palette + Working!
    3:44 - Tilemap Colliders
    4:27 - Layered Tilemaps
    5:27 - Outro

Komentáře • 66

  • @GameCodeLibrary
    @GameCodeLibrary  Před 11 měsíci +4

    In response to: "Why is the pixel per unit set to 15 instead of 16❓"
    You can try it out with 16x16 - but with exact sizing with sprites this can cause tearing: you’ll see white lines flickering between your tiles!
    To fix this I use the easy way of setting the pixel per unit to be one less, which means we have a bleed edge - an overflow for the sprites!
    There are two other ways I know to fix this:
    1. Manually edit your sprites to be bigger with a bleed overlay: so add a few extra padded pixels around all edges so it’s say 18x18, then you can use 16x16 in Unity safely! (Time consuming!)
    2. Use a sprite atlas (found in the 2D menu) where you add an entry for each sprite in your tile map.
    Since this is a quick and easy version, I did my lazy way which I use for small projects! In professional level production you can use one of the above methods.

    • @timothykessler5029
      @timothykessler5029 Před 6 měsíci +2

      not sure if the tearing is the same issue, but i just saw another video on tilemaps by MoreBBlakeyyy where he shows that turning off anti-aliasing in the project settings fixes this.

    • @blazeDev_vlog
      @blazeDev_vlog Před 5 měsíci +1

      You can fix this issue by just creating a sprite atlas of all sprites used with tiles. Hope it helps :)

  • @LukeCreates
    @LukeCreates Před rokem +2

    A couple days ago when I was looking in to this I would have loved this tutorial. Explain things so well.
    Thank you.

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem

      Thank you I’m glad you think so!
      Hopefully next time I can make a video you need when you need it! 😝🫶

  • @0Turtlez
    @0Turtlez Před rokem +4

    Thank you so much! I’ve been looking all day for a tutorial for exactly what you showed.

  • @nTu4Ka
    @nTu4Ka Před 9 měsíci +6

    You deserve a lot more subscribers.
    Really good quality tutorial!

    • @GameCodeLibrary
      @GameCodeLibrary  Před 9 měsíci

      Thank you I really appreciate that 🤝 I’ll keep working hard to put out helpful vids! 🙏

  • @SaintMemes701
    @SaintMemes701 Před 11 měsíci +2

    You make the best and the quickest tutorials and it helps a lot thankyou very much

    • @GameCodeLibrary
      @GameCodeLibrary  Před 11 měsíci +1

      You're welcome! I glad you like them!
      I used to always get impatient with slow CZcams tutorials, so I plan to make the best and most concise videos I can! 🤩

  • @user-iu2nc5pj3m
    @user-iu2nc5pj3m Před rokem +2

    Awesome!

  • @GameCodeLibrary
    @GameCodeLibrary  Před rokem +3

    On my Patreon you can get the package which includes this Tilemap and Rule Tile - so you don't have to set it up yourself:
    www.patreon.com/posts/tilemap...
    (My Patreon also includes all past and future code, packages and assets used on my channel!)

  • @analog_dreamer
    @analog_dreamer Před rokem +2

    Awesome tutorial, thank you

  • @teamofwinter8128
    @teamofwinter8128 Před 3 měsíci

    your voice is very soothing

  • @RadicalTrailers
    @RadicalTrailers Před rokem +2

    A fantastic Tutorial, nice and clear and easy to follow 👍

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +1

      Thank you so much! I really appreciate it 🥲 I worry if they’re either too fast or too slow, going to try find the perfect speed! Your comment helps my confident 🙏

    • @RadicalTrailers
      @RadicalTrailers Před rokem +1

      @@GameCodeLibrary Well I was able to follow, and I'm super new to Unity, I think you nailed the speed, what I really like is the bubbles you have pop up showing exactly what you are doing in the Inspector/project/Heiarchy and Such, It really does make it easier to understand 😃

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +1

      @@RadicalTrailers Yeah I had the idea for the text bubbles later on and I'm glad I added them!! Whenever I followed tutorials I'd forget what they'd said, so it's nice to have an on screen reference ☺
      I have lots of video ideas so hope some future ones help you too! Thanks again for your opinions, helps so much!
      🤠

  • @AlwynCho
    @AlwynCho Před 7 měsíci

    useful tutorial thankyou! keep good work

  • @abyssianknight736
    @abyssianknight736 Před 11 měsíci

    Just found your channel,its just like watching a video from brackeys, just as clear and entertaining, love it

    • @GameCodeLibrary
      @GameCodeLibrary  Před 11 měsíci +1

      Thanks so much! Getting the brackeys comparison is high praise haha - I'll try keep up the vids!

    • @abyssianknight736
      @abyssianknight736 Před 11 měsíci

      @@GameCodeLibrary looking forward to learning more from you 😁

  • @itsbarrex
    @itsbarrex Před 6 měsíci

    wow! easier than I thought! thank you for this tutorial, love it! keep it up =D

  • @Mimi_py
    @Mimi_py Před 2 měsíci

    Good for a refresher on how to do it, People new to unity might struggle to follow along, Helped me so I like though

    • @GameCodeLibrary
      @GameCodeLibrary  Před 2 měsíci

      Difficult to find the right balance sometimes - but I'm glad you enjoyed! Hopefully if it's too fast for new people, they can rewatch or pause it lots :p

  • @romanartyushkin2486
    @romanartyushkin2486 Před 7 měsíci

    Great stuff. Please do more.

    • @GameCodeLibrary
      @GameCodeLibrary  Před 7 měsíci

      I have lots and lots planned! Let me know if there is anything in particular that you'd like to see. :-)

  • @kozmobotgames
    @kozmobotgames Před 5 měsíci

    Amazing tutorial!

    • @GameCodeLibrary
      @GameCodeLibrary  Před 5 měsíci +1

      Thank you!

    • @kozmobotgames
      @kozmobotgames Před 5 měsíci

      @@GameCodeLibrary ever since I was a child, I was always dreaming about making games. Although I opened my first YT channel for traditional drawing when I was 19 years old, I started a game development channel one year later. I am proud to see how is my channel growing after two years of actively posting new videos every week or two weeks. I am happy to have so many views and positive reviews from people who watch my tutorials!

  • @llamasoxschwartz7185
    @llamasoxschwartz7185 Před rokem +5

    I love your voice

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem

      Thank you!! I try to sound the least annoying as possible 😂

  • @scoop9551
    @scoop9551 Před 10 měsíci

    How would you make a platform made from tileMap falling for example ? I have a script working for gameobjects I created ( Like a rectangle platform ) , but I can't attach those to tile maps ?

  • @johnathansuda570
    @johnathansuda570 Před 6 měsíci

    Any experience with incorporating navmesh with tile mapping?

  • @mysticowlgames
    @mysticowlgames Před 9 měsíci

    How would you work with sliding colliders or slopes in Rule Tiles? I am unable to figure it out

    • @GameCodeLibrary
      @GameCodeLibrary  Před 9 měsíci

      Hey! I haven't tried it out myself, but I've seen this cool video for handling slopes and rule tiles!
      czcams.com/video/dd1Fe3AiWdw/video.html
      However, it's a paid for tool.
      I haven't seen anyone else work with rule tiles and slopes! So you could manually add the slope on after painting your map out with rule tiles simple block shapes! Sorry I couldn't help more, good luck :-)

  • @GameCodeLibrary
    @GameCodeLibrary  Před 4 měsíci

    ❗❗❗😱📢 50% OFF LAUNCH SALE!! 😱👾❗❗❗
    BUY THE COMPLETE GAME TEMPLATE NOW!!!
    gamecodelibrary.itch.io/2d-platformer-template

  • @kaviyy
    @kaviyy Před 7 měsíci

    The used by composite part does not appear for me... what is the reason?

    • @GameCodeLibrary
      @GameCodeLibrary  Před 7 měsíci

      Sorry for such a late reply! Was away this week :p
      On your actual tilemap component, make sure you add a Tilemap Collider 2D and then a Composite Collider 2D.
      After the Composite Collider 2D is added, the tick box should appear on your Tilemap Collider 2D.
      When ticked, it should merge your multiple tile colliders into one big collider! If it doesn't appear to - try resetting your project and seeing if your collider has updated.
      Hope this helps!

  • @bluzenkk
    @bluzenkk Před rokem +1

    can you make a tutorial on using LDtk or Tiled. I think that will improve workflow than using the unity tile map edit.

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem

      I could do a video on the options for tilemaps other than unitys basic one! And show how to import with them all… I’m covering the basics of getting a project up and running in the easiest way right now, but I’ll get into details like this in the future!!
      Thanks for the suggestion 😊

    • @bluzenkk
      @bluzenkk Před rokem +1

      @@GameCodeLibrary thanks for keeping an open mind. I've been digging to find more tutorials on Tiled Edit and LDtk. cuz i saw a CZcamsr use Tiled and automated the workflow of adding collision and new tiles so effciently that makes the Unity Tilemap look so obsolete.

  • @edithasd2806
    @edithasd2806 Před 8 měsíci

    lol I solved it. Thanks a lot

    • @GameCodeLibrary
      @GameCodeLibrary  Před 8 měsíci +1

      I didn’t see the original problem but I’m glad you solved it 😝🙏

  • @EpicHashTime
    @EpicHashTime Před rokem +3

    Why is the pixel per unit set to 15 instead of 16?

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +6

      You can try it out with 16x16 - but with exact sizing with sprites this can cause tearing: you’ll see white lines flickering between your tiles!
      To fix this I use the easy way of setting the pixel per unit to be one less, which means we have a bleed edge - an overflow for the sprites!
      There are two other ways I know to fix this:
      1. Manually edit your sprites to be bigger with a bleed overlay: so add a few extra padded pixels around all edges so it’s say 18x18, then you can use 16x16 in Unity safely! (Time consuming!)
      2. Use a sprite atlas (found in the 2D menu) where you add an entry for each sprite in your tile map.
      Since this is a quick and easy version, I did my lazy way which I use for small projects! In professional level production you can use one of the above methods.
      Hope that helps!! Long reply 😇

    • @EpicHashTime
      @EpicHashTime Před rokem +3

      @@GameCodeLibrary Thanks. I tried setting my player sprite to one pixel smaller and it no longer looks like it's floating 👍

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +2

      I’m glad! It’s always good to try out things to see how it works for your game 😊

    • @Novastar.SaberCombat
      @Novastar.SaberCombat Před rokem

      It's always a good idea to give a little "wiggle room" to everything. Otherwise, collisions, layering, and even mechanics can look... well... too rigid and mechanical.
      In the original "Pac Man" game (1980's), controlling mr Pac guy allowed for "rounded" cornering during player manipulation. The ghost enemies were NOT permitted to do this. 🙂 This is why it was easier for players to gain ground and escape ghosts in "J-bends" or multiple curves as opposed to straightaways.
      What does this have to do with 15 pixels vs. 16? Well, the CORNERS of ledges can be rounded as well. This allows players to leap up to ledges (or fall from them) with less rigidity and blockiness. 🙂
      🐲✨🐲✨🐲✨

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +1

      @@Novastar.SaberCombat A great explanation!! 🤩

  • @battelbad12
    @battelbad12 Před 8 měsíci

    The moment I saw aseprite I immediately sub 😂

  • @dreamspheree
    @dreamspheree Před rokem

    I am using slopes in the tile map and the collider is not pixel perfect . And the character looks like it's floating

    • @GameCodeLibrary
      @GameCodeLibrary  Před rokem +1

      You can try using a polygon collider 2D and shaping that to your slope instead of the tilemap collider!
      I’ll try it out tomorrow to see if I can find something better if that doesn’t work for you 🙏

    • @dreamspheree
      @dreamspheree Před rokem +2

      @@GameCodeLibrary thanks! you're too good i'll check it out

    • @dreamspheree
      @dreamspheree Před rokem

      well i did some experiment, if i redraw the slopes in a new sprite sheet like 64x64 tiles (original is 16) i can see the tile collider is much more accurate... so weird unity over pass that

  • @FP-ih1lu
    @FP-ih1lu Před 2 měsíci

    super hard to follow along, I ran into 10 problems that you didn't run into, and nothing is actually explained for the viewer's understanding :(

    • @GameCodeLibrary
      @GameCodeLibrary  Před 2 měsíci

      That’s a shame I’m sorry! What went wrong? Hopefully you can find a slower video that works for you 🙏