Easy Tilemaps and Dynamic Auto Tiling - Unity 2D

Поділитися
Вставка
  • Опубліковано 22 лип 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

КОМЕНТАРІ • 68

  • @GameCodeLibrary
    @GameCodeLibrary  11 місяців тому +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 6 місяців тому +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 5 місяців тому +1

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

  • @0Turtlez
    @0Turtlez Рік тому +4

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

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

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

  • @nTu4Ka
    @nTu4Ka 9 місяців тому +6

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

    • @GameCodeLibrary
      @GameCodeLibrary  9 місяців тому

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

  • @SaintMemes701
    @SaintMemes701 Рік тому +2

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

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +1

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

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

    Awesome tutorial, thank you

  • @user-iu2nc5pj3m
    @user-iu2nc5pj3m Рік тому +2

    Awesome!

  • @abyssianknight736
    @abyssianknight736 11 місяців тому

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

    • @GameCodeLibrary
      @GameCodeLibrary  11 місяців тому +1

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

    • @abyssianknight736
      @abyssianknight736 11 місяців тому

      @@GameCodeLibrary looking forward to learning more from you 😁

  • @llamasoxschwartz7185
    @llamasoxschwartz7185 Рік тому +5

    I love your voice

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

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

  • @RadicalTrailers
    @RadicalTrailers Рік тому +2

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

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

  • @totheMoon-qv4jn
    @totheMoon-qv4jn 9 днів тому

    Thank you, it really helped me 💪

  • @teamofwinter8128
    @teamofwinter8128 3 місяці тому

    your voice is very soothing

  • @itsbarrex
    @itsbarrex 6 місяців тому

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

  • @Mimi_py
    @Mimi_py 3 місяці тому

    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  3 місяці тому

      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 7 місяців тому

    Great stuff. Please do more.

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому

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

  • @kozmobotgames
    @kozmobotgames 6 місяців тому

    Amazing tutorial!

    • @GameCodeLibrary
      @GameCodeLibrary  6 місяців тому +1

      Thank you!

    • @kozmobotgames
      @kozmobotgames 6 місяців тому

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

  • @scoop9551
    @scoop9551 10 місяців тому

    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 7 місяців тому

    Any experience with incorporating navmesh with tile mapping?

  • @GameCodeLibrary
    @GameCodeLibrary  4 місяці тому

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

  • @mysticowlgames
    @mysticowlgames 9 місяців тому

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

    • @GameCodeLibrary
      @GameCodeLibrary  9 місяців тому

      Hey! I haven't tried it out myself, but I've seen this cool video for handling slopes and rule tiles!
      ua-cam.com/video/dd1Fe3AiWdw/v-deo.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 :-)

  • @kaviyy
    @kaviyy 8 місяців тому

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

    • @GameCodeLibrary
      @GameCodeLibrary  7 місяців тому

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

      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 Рік тому +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 UA-camr use Tiled and automated the workflow of adding collision and new tiles so effciently that makes the Unity Tilemap look so obsolete.

  • @AlwynCho
    @AlwynCho 7 місяців тому

    useful tutorial thankyou! keep good work

  • @edithasd2806
    @edithasd2806 9 місяців тому

    lol I solved it. Thanks a lot

    • @GameCodeLibrary
      @GameCodeLibrary  9 місяців тому +1

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

  • @EpicHashTime
    @EpicHashTime Рік тому +3

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

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

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

    • @GameCodeLibrary
      @GameCodeLibrary  Рік тому +2

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

    • @Novastar.SaberCombat
      @Novastar.SaberCombat Рік тому

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

      @@Novastar.SaberCombat A great explanation!! 🤩

  • @battelbad12
    @battelbad12 8 місяців тому

    The moment I saw aseprite I immediately sub 😂

    • @GameCodeLibrary
      @GameCodeLibrary  8 місяців тому

      Lol aseprite superiority 👌

    • @battelbad12
      @battelbad12 8 місяців тому

      @@GameCodeLibrary wise word 🙏

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

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

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

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

      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 2 місяці тому

    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  2 місяці тому

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