Tilemap in Unity (Build Worlds Easily)

Поділитися
Вставка
  • Опубліковано 13 чер 2024
  • Let's learn how to use the Built-in Unity Tilemap!
    🌍 Get the Complete Builder-Defender Course! ✅ unitycodemonkey.com/coursebui...
    👍 Learn to make an awesome game step-by-step from start to finish.
    Interested in a Complete Visual Scripting Course?
    unitycodemonkey.com/intereste...
    Custom Tilemap in Unity with Saving and Loading
    • Custom Tilemap in Unit...
    Powerful Generics Added! Grid System
    • Powerful Generics Adde...
    Grid System in Unity
    • Grid System in Unity (...
    Character Controller in Unity 2D
    • Character Controller i...
    🌍 Get Code Monkey on Steam!
    👍 Interactive Tutorials, Complete Games and More!
    ✅ store.steampowered.com/app/12...
    If you have any questions post them in the comments and I'll do my best to answer them.
    🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
    See you next time!
    📍 Support on Patreon / unitycodemonkey
    🤖 Join the Community Discord / discord
    📦 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
    📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
    #unitytutorial #unity3d #unity2d
    --------------------------------------------------------------------
    Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
    I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
    You can see my games at www.endlessloopstudios.com
    --------------------------------------------------------------------
    - Website: unitycodemonkey.com/
    - Twitter: / unitycodemonkey
    - Facebook: / unitycodemonkey

КОМЕНТАРІ • 114

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  3 роки тому +10

    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Get my Courses unitycodemonkey.com/courses or Support on Patreon www.patreon.com/unitycodemonkey

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

      Btw you can flip the selected tile with "X" or "Y" and rotate it with "comma" or "period". No need for extra versions.

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

      Well-made and informed. Only thing I'd do differently is turn off AA in a 2D tilemap game, since it's not necessary and might waste performance. Turning it off gets rid of the gaps between tiles with no extra steps. Also, I'd put obstacles and things like grass in a separate layer instead of generating colliders for all of them and erasing the grass colliders by hand. If you miss any and forget them it could create some unexpected collisions in your game.

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

      i know Im randomly asking but does anybody know a way to get back into an instagram account??
      I was dumb forgot my login password. I would love any help you can give me

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

      @Johnny Matthias Instablaster :)

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

      @Emory Zayn thanks for your reply. I got to the site thru google and I'm trying it out atm.
      I see it takes quite some time so I will get back to you later with my results.

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

    💬 Here's a really useful Unity tool to help you build levels super fast!
    It's super versatile, lets you build Rectangular, Isometric and Hexagonal maps.
    Interested in the Visual Scripting course? Click here! 🌐 unitycodemonkey.com/interestedvscourse.php

  • @surgetale
    @surgetale 3 роки тому +5

    Thanks for the tip with the Sprite Atlas to fix the cell gap between tiles. I am currently working on my own game and this was a huge help, since I couldn't figure out how to get rid of them. Perfect timing :)

  • @ralphjimenez3191
    @ralphjimenez3191 3 роки тому +4

    What a wonderous hour to wake up to a new coding lesson with Kode Monkee XD. It's like 2 in the morning here.

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

    Great tutorial! Thank you very much for this in-depth look at tiling :)

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

    Great to see another video! Thanks for all your content!

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

    Awesome as always! Keep up the awesome work you do.

  • @MatthewChowns
    @MatthewChowns 3 роки тому +25

    Some follow up videos I think would be great are: auto-tiling, programmatic tiles, and procedural generation. What I'd love to see though, is how to take the tilemap system from your previous videos and extend it to cover the main features of unity's tilemap. ie. editor workflow. Or maybe merging the two, so you can take advantage of unity's pre-built system but be able to easily add data or other features to each tile via the custom tilemap

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +8

      Yup I would like to look into the Rule Tile, it does seem quite interesting!

    • @CSNomad
      @CSNomad 3 роки тому +3

      @@CodeMonkeyUnity I know I'd certainly love to see more tutorials around tile-maps (Particularly Procedural Generation with Perlin Noise, Rule Tile, Programmatic, etc.)

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

      @@CodeMonkeyUnity after two year i would be happy see a procedual generation for tile map and level design. plus how cloud change tiles in code ?

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

    Exactly What i was looking for Thanks 🙏

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

    I wouldn't have figured out how to remove the gaps between cells without you. Thank you

  • @hanavargas666
    @hanavargas666 3 роки тому +3

    Thanks, I didn't know about the Atlas and that solved a problem I was stuck on for weeks

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

    Thank you so much! This helped me a ton

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

    A really useful video. There are many nuances that I didn't use... I'm Waiting for your cool courses, I like your code and step-by-step guide)))

  • @HenonChesserPlus
    @HenonChesserPlus 2 роки тому +2

    Now that about a year has passed it'd be cool to revisit this subject and look into some of the new 2d/tile map tools items like the rule tile. It's incredibly powerful but like many fresh unity tools incredibly limited and 'black-boxy'. I've been trying to cobble together a hybrid of Unity tilemap and the code based tilemap from your previous tutorials. It's coming along well enough, but I'd love to see what a more adept unity dev would come up with. Like other commenters I'd also love to see how both systems could be used with procedural generation as well as how to store data in cells with unity's tilemap and how to serialize that data as well as the tile map data.

  • @user-xb6fl9ri6g
    @user-xb6fl9ri6g 3 роки тому

    thank the lawd, I have been getting failed imports from tiled - this actually looks easier to just do it direct. Ty so much for doing these.

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

    Another great Video.👍

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

    SPRITE ATLAS!!- you are the first person I have found talking about this, it solved a "shaky sprites" issue I was having with tilemap sprites in < 1 minute :). Thankyou

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

      Another solution, if you are going for a pixelated look, is to change the filtering on the sprites from bilinear to point (no filtering). Sometimes these gaps are the result of the filter trying to interpolate the edge tile colors with non-color outside of the sprite, making the edge pixels semi-transparent.

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

    You should really use a Composite Collider along with the Tilemap Collider. It drastically improves performance and simplifies the colliders so that each individual tile isn't producing a collider.

  • @Jay-og4yb
    @Jay-og4yb 3 роки тому

    What if I were to add in, say, a tree using the same concepts. Would I then, be able to program the tree, to be able to be cut down?
    How would I go about that? Would I have to hand place any sprites that have more functionality like that?

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

    Hey Code Monkey, do you have a video of using 2D tilemaps in 3D, i have it sort of working however i cant seem to get palletes to work nicely with it, they appear like side perspective in pallete editor cells rather then seeing the tiles as squares like you would in a 2D game, if i use a GameObjectBrush i can select from the list and paint and it works fine, but i'd love to get the pallete working as it does in 2D so i can quickily select the objects to paint onto 2D grid

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

    Great work bro. Please make a video about shooting method like apex legend

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

    Nice video.

  • @fredtchiadeu1089
    @fredtchiadeu1089 5 місяців тому

    Thanks for the tutorial, I added a box collider 2d on my character and Tilemapcollider + Composite collider to my map, but my player is still passing throught

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

    I LOVE THIS VIDEO I THOUGHT ABOUT THIS FOR 12 HOURS AND THEN U HELPED ME, WHO NEEDS BRACKEY'S WHEN WE HAVE YOU

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

    Thanks for great guide! I am creating a tower defense game, So Towrs are only placed on the green grass. How can i make this work quick? how can i let the code understand that the area is the green one so that i can only place there? Like we did it on your tower defense course, we coded a radius and collider recognizition so that we cant put same object so near. So it needs to be similar idea. But i am new to tiles and i dont know how to do that (placing the tower only the green grass)

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

      You can use Tilemap.GetTile to get identify the Tile on a certain position docs.unity3d.com/ScriptReference/Tilemaps.Tilemap.GetTile.html
      Then identify if that tile type is a valid building spot or not.
      If your towers occupy more than one tile just test the neighbours as well.
      Or maybe, add a tilemap collider onto the buildable tiles and do a physics query

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

    Can you have mulitple layers? So you can have old school style parallax scrolling to give the illusion of depth

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

      Yes I talk about different layers in the video. Although parallax would involve you moving the tilemaps ua-cam.com/video/wBol2xzxCOU/v-deo.html

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

    Another easy fix for the cell gap is to make them 1 pixel less in the spritesheet edit section, so if it’s 16x16 tiles put 15 and there will be gap. The atlas is better but for quick jams or something that other method works fine. Btw is there a way to make a tile appear below characters when in front and above characters when behind according to its pivot? Or would that particular case require it to be an object? For instance if you have a second level (height wise) in the map, how do you be infront of the top portion cliff when on that second level, but then able to go behind for depth when on the lower level? Hope that makes sense xD

    • @Jay-og4yb
      @Jay-og4yb 3 роки тому

      I can definitely see the sprite atlas thing as a quick fix that will likely cause issues in bigger more complex worlds.

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

    bro the tile atlas literally saved me hours of work lol

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

    Is possible to do a procedural tile map generator? Like scripting the width and hight of a room and let the code generate the tilemap? If you know how, pls let me know!

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

      You can set a tile through code but this only handles the visual, the generation part can be done in a million different ways.

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

    what would be your approach for making tile transitions from grass to sand, when your tilemap is procedurally generated? How can i put in the "mixed" tiles correctly? i would like to obtain "smooth" transitions and not see the square edges.

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

      Either you draw some tiles with that transition and place them, or maybe you use a mask and a shader to do the transition, kind of like Unity Terrain

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

    Great video
    Can you make it have components for example when you put it its already have a script
    (Sorry if my English is bad)

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

      Yup, the tilemap runs on a normal game object so you can add scripts onto it and interact with the tilemap through code

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

      @@CodeMonkeyUnity thanks

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

      @Ahsan Azizan thanks

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

      @@CodeMonkeyUnity i was searching how to do this

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

    so, i have a some small sprites like in the video, but i also have a larger building spritle. i there a way to make that work?

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

      Either split your building sprite into parts, or make a second tilemap with the size of the building

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

      @@CodeMonkeyUnity ok thanks

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

    thank for great tutorial. you can share assets of this tutorial

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

    Code monkey my pc performance are so low he can only run old versions of unity that means the new plugins are so pointless for me do you think I must give up or keep on game development?

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

      Sure you can use an older Unity version, you can build almost any game with old versions.
      I started working with Unity 3 all the way back in 2013 and managed to build several very complex games with it.

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

      @@CodeMonkeyUnity Wow well done thank you so much I will keep up on making games

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

    I cant find Tile palette why?

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

    @Code Monkey Pls help me!!! In my Scene I made many Emptys (Stages for the Endless Runner). I provided each of the with a Grid, so that I can put Tilemaps into them to easily create the platforms. But the Tilemaps have a lot more space than just the area that is filled with tiles. How can I fix this so that only the space where I drew tiles in is part of the tilemap object? Or is someting different correct? I googled a lot and I hope you will help me. Love your tutorials,
    David

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

      What do you mean by space? The Tilemap will only display where there are tiles, the empty space where there are no tiles isn't an issue

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

      @@CodeMonkeyUnity I mean if I eraze tiles the map still is bigger. I just want to make moving platforms but I think the position of these makes the movement weird. Maybe the tutorial is just bad but I didnt find a really good one. If you make one I'd instantly like it.

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

    You didn't explain why the atlas solves the gaps between tiles? Isn't the gap because you didn't get rid of filtering and compression on the sprites?

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

    My Unity Editor crashed a couple times when I used Tilemap.

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

    is there a wat to make it so you can only use the tilemap in certain locations?

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

      way*

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

      What do you mean? You can use it anywhere which means you can use it only where you want it

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

    First 🥇

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

    i am not getting the slice optiopn

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

    Do you have a tutorial for 2d but with sideways view (platformer). I am making this and it is my goal to release my first game in 2021

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

      I made a simple jump and double jump here ua-cam.com/video/DEGEEZmfTT0/v-deo.html

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

      @@CodeMonkeyUnity Thanks!

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

      @@XEAZUR did you do it

  • @MRX-qp5ne
    @MRX-qp5ne 3 роки тому

    Can you made a video how to make a tile map in photoshop and export it

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

      You just draw it in any image program you want, for exporting you just make an image, a PNG or JPG, anything works

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

    Will you make an action platformer course?

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

      By that do you mean enemies? The Platformer game doesn't have enemies but the Action RPG does so you can learn to be able to combine both into one game.

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

      I just wanted a regular course from you regarding making action platformer. Just like your Builder-Defender course with regular programming and some advanced concepts like modular game design. There are not many teachers like you who explains so well. Thanks for replying.

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

      @@KalponicGames I definitely expect the same )

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

    How does it work with walk-behind tiles? Say, a tall tree?

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

      You mean sorting? It should automatically sort things within the same tilemap automatically. As for having other dynamic objects in between the tiles I'm not entirely sure, I've only been using objects the same size as the tiles

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

      @@CodeMonkeyUnity Yes, I meant interacting with the rest of the game. Characters walking through the scene, for example, or players being able to place object in the scene, and have other moving elements (npcs, critters, etc) be correctly sorted while moving around them.
      EDIT: this, basically: preview.redd.it/zsrfe2239bv51.gif?format=mp4&s=0843b485f1092969390ae1135e60907d724ac2d1

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

    Where did you make the sprites?

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

      I drew them in Photoshop

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

      @@CodeMonkeyUnity can you also do it with UPA toolkit? This is an asset for pixelart.

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

    So~ I’m not the smartest and really want to figure this out. I’ve made a character and my tilemap. But my character is always under the tile map when I start the game…How can I fix this?

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

      Check the sorting order unitycodemonkey.com/video.php?v=5_BwFB-1dAo
      Also make sure the Z is on 0

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

    Why not just turn off antialiasing to get rid of the gaps? That's only needed for 3D and might slightly improve performance to turn it off in a 2D game anyways, right?

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

      It's also useful in 2D unless you're working with Pixel art

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

      @@CodeMonkeyUnity I see. I don't do a lot of 2D stuff, so I wasn't aware of any other benefits to AA. But in a tilemap game it's often pixel art we're using anyway.

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

    I have problem with organization of tilemaps. For example if you want to make something like forest you cannot use same tree tiles at same position.
    You would need to use multiple tiles. Otherway is use the Z position in the tilemap. But also this makes difficult to eraese later because you don't know what Z position was used.
    Also what if you designed a map part lets say gardenn, with fence and buildings, crops. And you want to have copy and paste? It does not work because you tile palette tools cannot copy multiple tilemap tiles and same time. That's are things which makes difficult to work with it.
    I give you a scenario. You placed a building, you placed a wall as order 1 to draw it after the tree.. now you want to draw another tree as foreground.. so you use for this already 3 tilemaps. Now if you have followers and bushs your tilemap grows.
    And now... if you have map areas with same setup.. you end up with tons of tilemaps.

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

    I could’ve had this a month ago 😂

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

    Where do i get the tile map textures

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

      There's plenty of free texture packs on the unity asset store

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

      @@CodeMonkeyUnity I was searching for one and I couldn't find a good one is there any you would suggest if so pls send link Thanks So much For The Reply.

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

    Should probably take a look at the RuleTile, instead of rotating the same tile 3 different times.

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

      In this case I don't think that would work since the edges are being placed on a second tilemap and not on the same one

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

      @@CodeMonkeyUnity Yeah your right, I overlooked that.

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

    Ker... Kermit...?

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

    it isnt working

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

    ok

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

    ~~~

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

    dude when you make toutorials you need to cool down a little

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

      You mean slow down? Everyone learns at a different pace so feel free to hit the pause button whenever you need to.
      Just focus on making sure you understand what it is you're trying to learn regardless of how long it takes.

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

    лучше бы сделали спрайт мап

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

    WHYWHYWHWEYWEY SPRITE MODE DOESNT FUCKING EXIST WHYWHY HWEPOSG