Commenting to boost engagement. You're great at making videos like this, you didn't waste time with an intro, your voice is calm and slow and not annoying to listen to. Thank you!
If for some reason you can't find the "Tile Palette" option, click the "Window" tab at the very top, go to "2D" and click "Tile Palette". Then you can drag it onto the inspector like in the video.
Man u have a lot of potential of being a great teacher just like brakeys so plz don't stop u providing a really really cool content keep it up It's the first time i see ur channel and i think u doing great job
@@vectorbread don't worry bro if u keep making these cool videos am pretty sure u'll be there in no time Am just saying that bcuz i really love ur videos and many people will love ur work too
This is great!! Just got into tilemaps for unity. This has been a great help! Thank you so much! I'm subscribed and can't wait for your next video!! :)
great video! quick question tho is there a way to give the tiles collistion without creating 1 collider per block painted (the performance doesn't like that so much if i give the prefab where i paint with a collider)
The answer is yes and no. You can build your own script that will generate optimized box colliders from your tilemap (it's not easy), or you can extract the mesh from the tilemap and use it in a mesh collider (which is unoptimized, but still better than the example in this video) Best option to me is to use an asset on the Asset Store called Autotiles 3D
Thanks for the video its basic and efficent. But i want to ask you guys something my models size doesn't match with other models when using GameObject pallette (some are big some are small). How can i edit my models easily.
Love your channel and this video has helped me so much. I love your slow, calm, reassuring style; it's refreshing on RUclips to see someone who understands when to let your words breathe; I'm still learning how to do that myself. I'm creating a top-down game with pixel art that still has a Z plane, and this has really helped me create that world much faster the way I want to, just like painting a top-down map. Hope you come back to make more content, if you want to!
Hello, thank for the video! I'v been trying to use the HasTile to verify is the ground tile map has a game object set but without any luck... do you know how could I do samething like that? I'm trying to verify if the player has a place to walk but HasTile always return false...
Hi Diogo! Unfortunately with this basic approach the Prefabs themselves are not considered Unity Tiles so we are placing them in the correct position, but the data in the Tilemap component is not being updated. I've made a Unity Component called `TileUnit` which will tell the Tilemap that the game object is taking up the tile at its position. Here is the `TileUnit.cs` File: gist.github.com/vectorbread/52ed2111f483a07e4a6520a116d6c1b7 If you add the `TileUnit.cs` file to your project and add the component to your Prefabs then the Tilemap will automatically have its data updated when you start the game.
@@vectorbread First of all, thanks a lot for the tutorial, it is great and straight to the point and has helped me a lot. I've used your script and now HasTile() returns true as expected, but tilemap.GetInstantiatedObject() does not return anything. Any chance do you have a suggestion? Thanks a lot
Thanks! Yeah if you `Instantiate()` your prefabs with the Tilemap as the parent and use the Tilemap's `GetCellCenterWorld()` function to calculate the world position of the prefabs.
Hi, I've just added the "2D tilemap" from package manager. However, at the brush window I am not having "gameobject.brush"... Where it is? I couldn't find this problem on google too :(((
Hi Ceren did you also install the "2D Tilemap Extras" package? That package should have the brushes in it, but it is hidden by default in the Package Manager see 0:29.
I haven't heard of this before but I can try to help. What version of Unity are you using? Can you share a screenshot somewhere? You can DM me on twitter if that helps twitter.com/VectorBread
when a I try to use the brush with the gameobject selected, I get this error: FloodFill not supported UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) ------- do you know why?
I'm not sure, but I'd guess its because the Game Object brush does not work with the FloodFill option for the Tilemap (or at least it doesn't work in all versions of the Tilemap Extensions). Likely it won't work unless someone made a custom version of the brush to fill out the FloodFill functionality.
I think you're asking if the channel is monetized. It's not because you need 1000 subs to be able to monetize. It is indeed RUclips's rules forcing ads on the video. From what I understand once I hit 1000 subs I can manually turn off ads on each video, but I hear it won't show up in search results much anymore if I do that. If I get that many subscribers I'll try turning the ads off or putting the ad at the very end so people can just watch without waiting for an ad.
It didn't show up for me either and it turned out to be because I was using a ver of Unity from 2019 or so, when I did the same search on a ver from 2022 the extras package showed up.
Your video is so helpful, thanks. But i have a question, what if i wanted to make a mountain or a hole? Should i make a separate 3d model or make new tilemap layers?
Nice video, exactly what I was looking for. Still, I've got one question. Is this better than instantiating tiles one by one as single objects speaking of performance? Thanks in advance
Great question! It's not any better for performance. In the levels I've built I haven't run into any performance issues so I wouldn't rush to optimize it, but there are a lot of options if you need to. Some of the more common optimizations include having multiple versions of the 3D tiles with only the visible faces you need, writing a script to group all the tiles into chunks and enabling / disabling the groups based on the camera position, and finally writing a script to generate a custom mesh based on the tilemap data.
hey, im encountering a problem where the ground is uneven. As a result, my character can't move smoothly across the ground. Do you have a potential fix for this problem?
@@mickssss there are a lot of possible ways you can run into this problem. If you’re using a Mesh Collider for your ground tiles then it’s possible the vertex positions need to be updated to be exactly the same between tile edges. Also the normals on those vertices might need to be fixed depending on your if your movement scripts use them. If possible I’d make simple tiles using box colliders to avoid having to deal with the 3D meshes.
You could technically do a 2d game, 2.5d game and a 3d game in different scenarios all in one with the right setup. I guess you would want to set up 3 different action maps for controls in the input system, since they would have different movements. I was already working on sort of a 2.5d game view that would go to 3d view during certain scenarios. I had pondered over tile maps, but didn't think it was too feasible. Composite 3d colliders would be somewhat nice.
Hi ! I was wondering if you knew how to make it so there is a collider attached to the tile map (or the grid) itself. Basically, when I place the blocs for the ground, they don't have any colliders. I don't want to assign a collider to every single ground block, or I don't want to make it at runtime via a script because of the lag. So my question is, are there any ways to make it so there is only one collider for the entire tile map ? If not, is there a way to make it so the colliders of all the ground blocks collapse together to make one ( I know it's possible with 2D tile maps using the tilemap collider 2D component, but I'm not sure if it is possible in 3D ). I hope I didn't make it too unclear... Thanks !
Hi Victor good question! Honestly the simplest approach is probably the best to start with. For every game object you use as a tile make it into a prefab and attach a collider for the tile. This will result in a ton of individual colliders, but if you use simple colliders like box colliders it probably won't be an issue for most games. Alternatively you can create a script to generate a mesh from scratch based on the tilemap you draw and you can rebuild this mesh from the scene view so it does not happen during the runtime. This will be more efficient and result in just 1 mesh, but there are lot more steps and its not something I can go over completely in a comment. This unity doc page has some examples of how to generate a mesh using a script as a starting point: docs.unity3d.com/ScriptReference/Mesh.html Sadly there is not built in 3D tilemap or composite collider like there is for 2D tilemaps in Unity. Hopefully Unity will expand their tilemap functionality to work better in 3D.
I really appreciate that even if the video is one year old, you keep answering questions, it really helps a lot ! And wow, didn't expected an answer this quick ! Thanks !
Hello! I was wondering if there is a way to add a gameObject tile to the tilemap through code because I can't seem to get tilemap.SetTile(Vector3Int position, TileBase tile) to work since I can't assign a gameObject as a tile through code. I've looked through the documentation, both the official tilemap and tile documentation but also the one for this package and can't find anything. Is there a way to do this or a better solution?
Hey Docdoozer! If you want to set a Tile through code you need a Unity Tile object to pass to the Tilemap. You can create new Tile objects using this line of code: ScriptableObject.CreateInstance(); I have a helper class that I often use which I place on game objects under a Tilemap and it will automatically find the Tilemap it is under and create a new Tile object and set the Tile on Tilemap. Here is the helper class I use: gist.github.com/vectorbread/52ed2111f483a07e4a6520a116d6c1b7
It’s hidden by default in the Package Manager. You need to change the Package Manager settings to show Preview Packages and change the Package Manager drop down to show all packages (instead of just the ones in your project).
@@vectorbread Just checked, the preview package now is only visible for UNITY 2020 onwards, We were using 2019 version and it didn't show preview package for tilemap. Just adding to information.
Hi Phatly the Tilemap Collider 2D only works for with the other 2D Colliders and if you have 3D models like the above video then you probably can't use it. You will probably want to use regular 3D Colliders on the individual game objects.
isn't that just gonna instanciate a bunch of separate gameObjects and not merge their meshes into one (as you should do if you want decent performance)
Yep you're right it is going to instantiate a bunch of individual gameObjects and components. I will say from my experience my old laptop could handle 10000s of simple cube tiles with no problem or optimizations. Also it seems like chunking the tiles into groups that you show / hide based on the camera location has the best improvement on performance. And of course creating a custom mesh like you said helps as well.
No unfortunately it doesn't. I'd love for Unity to introduce true 3D tilemaps so we can can get things like composite colliders. In my experience you can get a lot of box colliders in the scene before Unity starts to struggle. If you do do start having issues you can split your world up into chunks and hide the ones far from the player. Worst case you would have to write a custom script to generate the collider mesh from the tile data.
Great question unfortunately I don't know of a better approach yet. Ideally Unity will come out with a version of the Tilemap with 3D in mind which has a more natural way to handle multiple levels.
Yes it does work for hexgrids! If the brush is putting the model off center from the cell you clicked then play with the `Offset` and `Anchor` properties on your brush. I had to set both to 0 to make sure my model was put in the center of the hex cell.
This is great, definitely going to use this. Just one thing which could be improved. You have to dragdrop gameobjects to the brush all the time. Is there anything possible to speed this up?
I have found something helpful myself ;) you can use the 'Pick or select new brush (i)' tool in the toolbox. When clicking on a gameObject you can draw start drawing that object on other places on the grid. This makes it very fast. Also, the tilemap is just an editor tool. Every placed object is a normal gameObject as if it isn't placed with the tilemap. Which means you can move/rotate or do whatever with a gameobject after placing it in the tilemap.
First off, great video, very well put together and helpful! I have a quick question, I'm working on an RTS game and wondering because you are painting so many 3D box objects for the ground. Will it cause performance issues for large scale environments at all since Unity has to render so many boxes or would you say that's fine? The reason I ask is I'm currently using terrain builder for my levels but contemplating switching to a grid terrain as I was advised (and can see) the advantages of doing it for an RTS game. Appreciate any advice here as code and game optimisation is something I know very little about xD
For every single object the game will do a draw call. It's best to keep the draw calls to a minimum. Using the gameobject brush is fine and all, but should mostly just be used for prototyping an eviorment or sketching (unless your environment is really small then it don't really matter). If you want to optimize it you need to either make a copy of the tilemap in a program like blender or bind the meshes together into 1 with some coding. If you wanna challenge yourself do the latter since It's usually easier depending on what your doing and also a good learning experience about coding with 3D meshes.
Since your camera is going to be pointing at the ground, you could probably improve performance a lot just by enabling Unity’s built-in occlusion culling. Otherwise, because this is just scene geometry, you can mark the objects as static so that they get batched, which massively saves on draw calls. And then, if you’re still having problems, consider merging and baking the meshes so that they’re essentially treated as one big “ground” object instead of many objects.
Thanks @RepDev and @DisturbedNeo. I've since stuck with Unity's terrain tool since it seems more straightforward but will keep your advice in mind as I build up more experience moving forward.
Not sure. The brush should show up after you install the 2D Tilemap Extras. What version of Unity are you using? And which version of the 2D Tilemap Editor package did you install?
Yeah they are normal game objects so you can put any custom scripts you want on them and after painting them you modify their properties individually if you want. Also you can make prefabs of game objects with different custom data and paint which ever prefab you want so they don't all have the same starting data.
Yes they are still loaded by the computer. If you wanted to improve performance you could write a script to group the cubes into chunks and hide / show the chunks depending on the distance / direction from the camera. But I would avoid adding this extra logic until you start seeing issues in performance. Usually the computer can handle a lot more cubes than we'd expect.
What about the performance? Looks like each ground tile created with the brush also creates a new game object on the scene. Is this good or does it ends up generating a bad performance?
Good question. Its certainly not an optimized approach so performance may eventually become an issue. But when I played around with it Unity had no problem with pretty large amounts of tiles, so I would not worry about performance for most games. If you end up building a truly massive open world game with 3d tiles then you'll want to add a script which will group the tiles into chunks and only show the closest chunks to the player (which is pretty standard for any large map in a video game).
Good question!! At first I thought the Orientation property on the GameObject Brush should rotate the game objects, but when I tried it out today it was using a Quaternion to set the rotation which is pretty unintuitive from the Editor. So unfortunately with the latest version of the Tilemap Extras I don't see an easy way to rotate the tiles. You can manually rotate the GameObjects after placing them or you can place your GameObject under another parent GameObject and rotate it under the parent in the Prefab editor then paint the parent GameObject.
I usually make a new tilemap for each floor and set the offset on the brush to be the height of the floor I'm painting on. You can see me doing this at 2:31. I don't think you can 9-slice like 2D can. Unfortunately a lot features are missing when you try to use tilemaps for 3D. I hope Unity will release an update with better 3D support.
Is this method any more/less performant than having gameobjects be instantiated on runtime? The reason I ask is because I am working on a procedurally generated open world game, and I will be instantiating maps at runtime anyway. I'm currently using an isometric tilemap, since it keeps active gameobjects to a minimum. Does this spawn a seperate gameobject for each active tile, or is it more similar to the 2D tilemap?
Good question this method is just instantiating game objects. So each painted tile will have a separate game object. If you are worried about performance I would work on grouping the tiles into chucks and only show the chunks which are near the player during runtime. If you still see performance issues with chunks then, you'd likely need to create a custom 3D mesh based off the tilemap data instead of relying on tiles or gameobjects. Each of these performance enhancements can be time consuming to create, so I'd hold off until you really need them.
No its not optimized like 2D. I'd love for Unity to release an update with true Tilemap support for 3D. But you'll probably be surprised how far this unoptimized approach will go in a lot of games it will work fine. If you do run into issues the first optimization I would try is writing a script to group the tiles into chunks and hide and show chunks based on how close they are to the player.
Good question! The easiest way is to add the collider to the ground tile prefabs you plan on using before painting with them. So for the ground tiles in my video I'd add a BoxCollider to the prefab.
Hey, thanks so much for sharing this! I have a question tho...I want the player to be able to instantiate an object (lets say a tree in your case) via clicking on the map. So in theory there should be a way to do the same "painting" thing through code right? I have however not found a solution to instantiate these Brush Objects in code. Any idea on how to go about this?
Hi Ramon! Good question and unfortunately this video won’t help in your scenario. You’ll need to a script that figures out where the user has clicked on the tilemap and instantiates the prefab at that position. Here is an example script I made that does this: gist.github.com/vectorbread/fac2fcacec189cded8c7cc79e8a4fa50 It works by having a collider in your scene that represents the bounds of your tilemap. When the user clicks the screen it shoots a ray and sees where it lands on the collider. Then it converts that position to the center of the cell before instantiating your prefab.
@@vectorbread Thanks! I was tinkering with the internal ObjectBrush class that is used to paint objects via the UI and even got it to work by invoking it's Paint method, but that majorly messed with the physics loop and somehow seemed to break everything. Simply instantiating a prefab myself (at the correct position) works - thanks for the example :) The video is still super useful because I never knew you could swizzle the axis on the tilemap and that there even is the option to place real objects. That's really neat!
What kind of interaction did you have in mind? If you mean physics then you could add Colliders to the game objects you paint and your game characters could then walk on the tiles.
@@Rubberduckerino Oh I see what you mean now! You would need a custom script to listen for the user input and then get the position on the map where to place the game object. Here is an example script called `MapClick` which will shoot a ray where ever you click and place the prefab in the cell you clicked on. gist.github.com/vectorbread/fac2fcacec189cded8c7cc79e8a4fa50 For it to work your ground tiles will need a collider for the ray to find.
Straight to the point, I knew everything I needed to know after no more than 4 minutes. Subbed and will check out your other content!
Agree.
I watched multiple tutorials that were much longer than this one that didn't explain it as well as this video did in 4 minutes, thank you.
Commenting to boost engagement. You're great at making videos like this, you didn't waste time with an intro, your voice is calm and slow and not annoying to listen to. Thank you!
Totally agree. I would love to see some more videos on this subject from you. Great work!
If for some reason you can't find the "Tile Palette" option, click the "Window" tab at the very top, go to "2D" and click "Tile Palette". Then you can drag it onto the inspector like in the video.
the hero we all need
Thanks
ty buddy
👍tankyou
Thank you!!! Saved my life from project
Man u have a lot of potential of being a great teacher just like brakeys so plz don't stop u providing a really really cool content keep it up
It's the first time i see ur channel and i think u doing great job
Thanks I really appreciate that! Brackeys is one of my favorites as well.
@@vectorbread don't worry bro if u keep making these cool videos am pretty sure u'll be there in no time
Am just saying that bcuz i really love ur videos and many people will love ur work too
Simple, yet perfectly to the point! Thank you!
Thanks for the tutorial. I would recommend using different objects for edges and for landmass seperately, to increase performance
That's a great suggestion! I like that its a simple change which doesn't require any code.
omg thank you, i dont say this to every tutorial person but i love you
Incredible tutorial. One of the best I have ever seen, and I'm not kidding.
OMG I'm new to game dev and I've been searching if this was possible. Now to see if it works dynamically. Hard sub from me, thanks
Just had to add to the chorus. This is a fantastic and extremely useful tutorial. Much appreciated.
Finally, a proper tutorial. Thank you.
One of the best videos i have watched about level design. Thank you.
Thank you!
For anyone who wants to use polyperfect assets, set grid cell size to X=30 Y=30, Otherwise you will generate hundreds of objects
Good presentation, no bull shit, straight to the point. Thanks
Job well done!
This is great!! Just got into tilemaps for unity. This has been a great help! Thank you so much! I'm subscribed and can't wait for your next video!! :)
Not what I was looking for but wow, this is cool!
Thanks to you, I succeeded in making the tilemap.
Thanks man! For me, who are migrating from 2D mechanics, understanding what I need to change in Unity in order to adapt to 3D is essential. Wow!
This is fantastic! Exactly what I was hoping to find,
Thanks, this is just what I needed for my game!
Your voice is so calming
your vids are great. hope to see more in the future!
I didnt know that was an option in unity! Thank you for the video :)
great video! quick question tho is there a way to give the tiles collistion without creating 1 collider per block painted (the performance doesn't like that so much if i give the prefab where i paint with a collider)
The answer is yes and no. You can build your own script that will generate optimized box colliders from your tilemap (it's not easy), or you can extract the mesh from the tilemap and use it in a mesh collider (which is unoptimized, but still better than the example in this video)
Best option to me is to use an asset on the Asset Store called Autotiles 3D
Using 2d tool for 3d, Nice! Simple and totally useful for me. Thanks!
I love you, I needed that, it's very well explained
Your video and your voice are well made
this is amazingly helpful!! would love to see a tutorial on how to create a character on this kind of tilemap
Thanks for the video its basic and efficent. But i want to ask you guys something my models size doesn't match with other models when using GameObject pallette (some are big some are small). How can i edit my models easily.
Wonderful video. Succinct, easy to understand, and very helpful! Thank you for providing these insights.
Never subscribed so fast to a channel. Thanks for sharing it with us
Love your channel and this video has helped me so much. I love your slow, calm, reassuring style; it's refreshing on RUclips to see someone who understands when to let your words breathe; I'm still learning how to do that myself. I'm creating a top-down game with pixel art that still has a Z plane, and this has really helped me create that world much faster the way I want to, just like painting a top-down map. Hope you come back to make more content, if you want to!
you have perfect voice for unity tutorial .
You are such a AWESOME guy. Thanks a lot.
Great video! Looking forward to more tutorials. Glad I found the channel :)
This is fantastic I've got a few ideas for a possible project with this in mind.
This is absolutely amazing video to kick start my day 😍
This is so great, thank you mate!
Is there a way to switch between game objects on the same brush? There does not seem to be a clear way to easily change the object I am using.
Very concise and clear. Thanks!
I think I should explore 2D more. Didn't even know something like this existed. Thanks.
how do you switch to game object brush? unity isn't allowing me to
Great video, dude! Just subbed.
This is my favorite youtube video...
Hello, thank for the video! I'v been trying to use the HasTile to verify is the ground tile map has a game object set but without any luck... do you know how could I do samething like that? I'm trying to verify if the player has a place to walk but HasTile always return false...
Hi Diogo! Unfortunately with this basic approach the Prefabs themselves are not considered Unity Tiles so we are placing them in the correct position, but the data in the Tilemap component is not being updated.
I've made a Unity Component called `TileUnit` which will tell the Tilemap that the game object is taking up the tile at its position.
Here is the `TileUnit.cs` File:
gist.github.com/vectorbread/52ed2111f483a07e4a6520a116d6c1b7
If you add the `TileUnit.cs` file to your project and add the component to your Prefabs then the Tilemap will automatically have its data updated when you start the game.
@@vectorbread Ohh I get it now so that is how it is... Thank you a lot for your help!
@@vectorbread First of all, thanks a lot for the tutorial, it is great and straight to the point and has helped me a lot. I've used your script and now HasTile() returns true as expected, but tilemap.GetInstantiatedObject() does not return anything. Any chance do you have a suggestion? Thanks a lot
Right to the point! great content, subbed!!
Great video! got it working in minutes.
Additional question, is there a way to programmatically add to the tilemap at runtime?
Thanks! Yeah if you `Instantiate()` your prefabs with the Tilemap as the parent and use the Tilemap's `GetCellCenterWorld()` function to calculate the world position of the prefabs.
@@vectorbread ooh that does work, thanks for the fast response !
Great for beginners, Thank you!
Hi, I've just added the "2D tilemap" from package manager. However, at the brush window I am not having "gameobject.brush"... Where it is? I couldn't find this problem on google too :(((
Hi Ceren did you also install the "2D Tilemap Extras" package? That package should have the brushes in it, but it is hidden by default in the Package Manager see 0:29.
For some reason the package manger button isn't visible in the window. HELP PlEASE!
I haven't heard of this before but I can try to help. What version of Unity are you using? Can you share a screenshot somewhere? You can DM me on twitter if that helps twitter.com/VectorBread
when a I try to use the brush with the gameobject selected, I get this error: FloodFill not supported
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) ------- do you know why?
I'm not sure, but I'd guess its because the Game Object brush does not work with the FloodFill option for the Tilemap (or at least it doesn't work in all versions of the Tilemap Extensions). Likely it won't work unless someone made a custom version of the brush to fill out the FloodFill functionality.
Is your channel, Becuz i see ads is start and end , or just the RUclips new rules
I think you're asking if the channel is monetized. It's not because you need 1000 subs to be able to monetize. It is indeed RUclips's rules forcing ads on the video. From what I understand once I hit 1000 subs I can manually turn off ads on each video, but I hear it won't show up in search results much anymore if I do that. If I get that many subscribers I'll try turning the ads off or putting the ad at the very end so people can just watch without waiting for an ad.
@@vectorbread New Rule sucks , Bruh
Is it possible that I can place in-game gameobjects like roads on the tiles?
The 2D Tilemap Extras package doesn't show up for me. I couldn't find any solutions on the Internet either. Does anyone know where to find it?
It didn't show up for me either and it turned out to be because I was using a ver of Unity from 2019 or so, when I did the same search on a ver from 2022 the extras package showed up.
Already lost from step one. It took me like 10 minutes to find the assets.
Спасибо, что ты есть ♥
Your video is so helpful, thanks.
But i have a question, what if i wanted to make a mountain or a hole? Should i make a separate 3d model or make new tilemap layers?
I do not need it, but very good tutorial. Good and clear voice!
Nice video, exactly what I was looking for. Still, I've got one question. Is this better than instantiating tiles one by one as single objects speaking of performance? Thanks in advance
Great question! It's not any better for performance. In the levels I've built I haven't run into any performance issues so I wouldn't rush to optimize it, but there are a lot of options if you need to. Some of the more common optimizations include having multiple versions of the 3D tiles with only the visible faces you need, writing a script to group all the tiles into chunks and enabling / disabling the groups based on the camera position, and finally writing a script to generate a custom mesh based on the tilemap data.
hey, im encountering a problem where the ground is uneven. As a result, my character can't move smoothly across the ground. Do you have a potential fix for this problem?
@@mickssss there are a lot of possible ways you can run into this problem. If you’re using a Mesh Collider for your ground tiles then it’s possible the vertex positions need to be updated to be exactly the same between tile edges. Also the normals on those vertices might need to be fixed depending on your if your movement scripts use them. If possible I’d make simple tiles using box colliders to avoid having to deal with the 3D meshes.
You could technically do a 2d game, 2.5d game and a 3d game in different scenarios all in one with the right setup. I guess you would want to set up 3 different action maps for controls in the input system, since they would have different movements. I was already working on sort of a 2.5d game view that would go to 3d view during certain scenarios. I had pondered over tile maps, but didn't think it was too feasible. Composite 3d colliders would be somewhat nice.
Hi ! I was wondering if you knew how to make it so there is a collider attached to the tile map (or the grid) itself. Basically, when I place the blocs for the ground, they don't have any colliders. I don't want to assign a collider to every single ground block, or I don't want to make it at runtime via a script because of the lag. So my question is, are there any ways to make it so there is only one collider for the entire tile map ? If not, is there a way to make it so the colliders of all the ground blocks collapse together to make one ( I know it's possible with 2D tile maps using the tilemap collider 2D component, but I'm not sure if it is possible in 3D ). I hope I didn't make it too unclear...
Thanks !
Hi Victor good question! Honestly the simplest approach is probably the best to start with. For every game object you use as a tile make it into a prefab and attach a collider for the tile. This will result in a ton of individual colliders, but if you use simple colliders like box colliders it probably won't be an issue for most games.
Alternatively you can create a script to generate a mesh from scratch based on the tilemap you draw and you can rebuild this mesh from the scene view so it does not happen during the runtime. This will be more efficient and result in just 1 mesh, but there are lot more steps and its not something I can go over completely in a comment.
This unity doc page has some examples of how to generate a mesh using a script as a starting point:
docs.unity3d.com/ScriptReference/Mesh.html
Sadly there is not built in 3D tilemap or composite collider like there is for 2D tilemaps in Unity. Hopefully Unity will expand their tilemap functionality to work better in 3D.
I really appreciate that even if the video is one year old, you keep answering questions, it really helps a lot !
And wow, didn't expected an answer this quick ! Thanks !
Hello! I was wondering if there is a way to add a gameObject tile to the tilemap through code because I can't seem to get tilemap.SetTile(Vector3Int position, TileBase tile) to work since I can't assign a gameObject as a tile through code. I've looked through the documentation, both the official tilemap and tile documentation but also the one for this package and can't find anything. Is there a way to do this or a better solution?
Hey Docdoozer! If you want to set a Tile through code you need a Unity Tile object to pass to the Tilemap. You can create new Tile objects using this line of code:
ScriptableObject.CreateInstance();
I have a helper class that I often use which I place on game objects under a Tilemap and it will automatically find the Tilemap it is under and create a new Tile object and set the Tile on Tilemap.
Here is the helper class I use:
gist.github.com/vectorbread/52ed2111f483a07e4a6520a116d6c1b7
@@vectorbread I was just about to ask the same thing! Thank you for sharing that script!
hi, its not showing any other brush. Only showing default brush. How to see other brushes?
Have you installed the `Tilemap Extras` package from the Unity Package Manager? The extra brushes should appear after it is installed. 0:26
@@vectorbread now cannot see extra package on unity. please check.
It’s hidden by default in the Package Manager. You need to change the Package Manager settings to show Preview Packages and change the Package Manager drop down to show all packages (instead of just the ones in your project).
@@vectorbread Just checked, the preview package now is only visible for UNITY 2020 onwards, We were using 2019 version and it didn't show preview package for tilemap. Just adding to information.
Oh wow well that explains why you weren’t seeing it. Thanks for figuring that out it will help others who run into it too!
Strong video, thanks for explaining that. Are you working on a game rn? Keep it up!
straight up man , bada bing bada boom
Is each square tile object in your map 1m x 1m in the Unity environment? I'm interested in creating my own tile set in Blender.
They were in my video, but you can change the Cell Size of the Grid / Tilemap in the Inspector to a different size if you want.
@@vectorbread Thank you for responding to my question. This tutorial is really helpful for relatively new game designers!
with tilemap, which collider should be used? It's won't work with tilemap collider 2d
Hi Phatly the Tilemap Collider 2D only works for with the other 2D Colliders and if you have 3D models like the above video then you probably can't use it. You will probably want to use regular 3D Colliders on the individual game objects.
Is this capable of autotiling, or are the meshes just overlapping? Thanks for the video!
Thank you for your knowledge
isn't that just gonna instanciate a bunch of separate gameObjects and not merge their meshes into one (as you should do if you want decent performance)
Yep you're right it is going to instantiate a bunch of individual gameObjects and components. I will say from my experience my old laptop could handle 10000s of simple cube tiles with no problem or optimizations. Also it seems like chunking the tiles into groups that you show / hide based on the camera location has the best improvement on performance. And of course creating a custom mesh like you said helps as well.
Is there a way to make this procedural?
Installed it in Unity 2019.4.25 but its not showing game object brush option.
2d Tile Extra is not working from GIT and is now not available from package manager. Any help would be great
Hi, found the answer, I downloaded this from GIT separate and copied the brush scripts folders in assets.
@@techgeektw Thanks for this!
@@torq21 my pleasure
Does the 3d tilemap allow something similar to a composite collider,having loads of 3d colliders seems memory intensive
No unfortunately it doesn't. I'd love for Unity to introduce true 3D tilemaps so we can can get things like composite colliders. In my experience you can get a lot of box colliders in the scene before Unity starts to struggle. If you do do start having issues you can split your world up into chunks and hide the ones far from the player. Worst case you would have to write a custom script to generate the collider mesh from the tile data.
very informative and concise video, it was very easy to understand and implement but when i started paintint the tiles unity editor crashed :(
Is there a more efficient way to add mutliple levels vs adding new tilemaps for every tier?
Great question unfortunately I don't know of a better approach yet. Ideally Unity will come out with a version of the Tilemap with 3D in mind which has a more natural way to handle multiple levels.
Hey, thanks for the video!!!! Is this also able with hexgrids?
Yes it does work for hexgrids! If the brush is putting the model off center from the cell you clicked then play with the `Offset` and `Anchor` properties on your brush. I had to set both to 0 to make sure my model was put in the center of the hex cell.
@@vectorbread Thank you! Now it works :)
YOU ARE THE BEST :)
This is great, definitely going to use this. Just one thing which could be improved. You have to dragdrop gameobjects to the brush all the time. Is there anything possible to speed this up?
I have found something helpful myself ;) you can use the 'Pick or select new brush (i)' tool in the toolbox. When clicking on a gameObject you can draw start drawing that object on other places on the grid. This makes it very fast. Also, the tilemap is just an editor tool. Every placed object is a normal gameObject as if it isn't placed with the tilemap. Which means you can move/rotate or do whatever with a gameobject after placing it in the tilemap.
@@mediabass that's really good
@@mediabass can you show where is toolbox please? I can't find it
First off, great video, very well put together and helpful! I have a quick question, I'm working on an RTS game and wondering because you are painting so many 3D box objects for the ground. Will it cause performance issues for large scale environments at all since Unity has to render so many boxes or would you say that's fine? The reason I ask is I'm currently using terrain builder for my levels but contemplating switching to a grid terrain as I was advised (and can see) the advantages of doing it for an RTS game. Appreciate any advice here as code and game optimisation is something I know very little about xD
For every single object the game will do a draw call. It's best to keep the draw calls to a minimum. Using the gameobject brush is fine and all, but should mostly just be used for prototyping an eviorment or sketching (unless your environment is really small then it don't really matter). If you want to optimize it you need to either make a copy of the tilemap in a program like blender or bind the meshes together into 1 with some coding. If you wanna challenge yourself do the latter since It's usually easier depending on what your doing and also a good learning experience about coding with 3D meshes.
Since your camera is going to be pointing at the ground, you could probably improve performance a lot just by enabling Unity’s built-in occlusion culling.
Otherwise, because this is just scene geometry, you can mark the objects as static so that they get batched, which massively saves on draw calls.
And then, if you’re still having problems, consider merging and baking the meshes so that they’re essentially treated as one big “ground” object instead of many objects.
Thanks @RepDev and @DisturbedNeo. I've since stuck with Unity's terrain tool since it seems more straightforward but will keep your advice in mind as I build up more experience moving forward.
1:51 it dosn't appear this option to me. Why? :v
Not sure. The brush should show up after you install the 2D Tilemap Extras. What version of Unity are you using? And which version of the 2D Tilemap Editor package did you install?
@@vectorbread Unity version: 2020.1.6f1
2D Tilemap Editor: Version 1.0
It dosn't appear other version in the Package manager ;_;
Can you add custom data to these object and manipulate them after painting?
Yeah they are normal game objects so you can put any custom scripts you want on them and after painting them you modify their properties individually if you want. Also you can make prefabs of game objects with different custom data and paint which ever prefab you want so they don't all have the same starting data.
LIFESAVER THANK YOU
If you make a cube and use it to make the map, the parts that the player can't see are still loaded by the computer?
Yes they are still loaded by the computer. If you wanted to improve performance you could write a script to group the cubes into chunks and hide / show the chunks depending on the distance / direction from the camera. But I would avoid adding this extra logic until you start seeing issues in performance. Usually the computer can handle a lot more cubes than we'd expect.
@@vectorbread thks
clever! thanks for sharing!
What about the performance? Looks like each ground tile created with the brush also creates a new game object on the scene. Is this good or does it ends up generating a bad performance?
Also, can I use the grid to create some sort of tactical movement or is it just to paint?
Good question. Its certainly not an optimized approach so performance may eventually become an issue. But when I played around with it Unity had no problem with pretty large amounts of tiles, so I would not worry about performance for most games. If you end up building a truly massive open world game with 3d tiles then you'll want to add a script which will group the tiles into chunks and only show the closest chunks to the player (which is pretty standard for any large map in a video game).
OHHHHHHHHH! Are you a genius?
this awesome omg !!
Can u rotate the game objects on the tilemap? How to do it?
Good question!! At first I thought the Orientation property on the GameObject Brush should rotate the game objects, but when I tried it out today it was using a Quaternion to set the rotation which is pretty unintuitive from the Editor. So unfortunately with the latest version of the Tilemap Extras I don't see an easy way to rotate the tiles. You can manually rotate the GameObjects after placing them or you can place your GameObject under another parent GameObject and rotate it under the parent in the Prefab editor then paint the parent GameObject.
Can you do multiple floors? Any way to 9-slice it like in 2D if so?
I usually make a new tilemap for each floor and set the offset on the brush to be the height of the floor I'm painting on. You can see me doing this at 2:31. I don't think you can 9-slice like 2D can. Unfortunately a lot features are missing when you try to use tilemaps for 3D. I hope Unity will release an update with better 3D support.
Thank you!!!!!!! Nice tutorial!
Thanks for the tutorial
Holy duck, i was really wasting my time doing a level with probuilder, this looks better :D
Is this method any more/less performant than having gameobjects be instantiated on runtime? The reason I ask is because I am working on a procedurally generated open world game, and I will be instantiating maps at runtime anyway. I'm currently using an isometric tilemap, since it keeps active gameobjects to a minimum. Does this spawn a seperate gameobject for each active tile, or is it more similar to the 2D tilemap?
Good question this method is just instantiating game objects. So each painted tile will have a separate game object.
If you are worried about performance I would work on grouping the tiles into chucks and only show the chunks which are near the player during runtime. If you still see performance issues with chunks then, you'd likely need to create a custom 3D mesh based off the tilemap data instead of relying on tiles or gameobjects.
Each of these performance enhancements can be time consuming to create, so I'd hold off until you really need them.
That's interesting! Is it as optimised as 2D tiles?
No its not optimized like 2D. I'd love for Unity to release an update with true Tilemap support for 3D. But you'll probably be surprised how far this unoptimized approach will go in a lot of games it will work fine. If you do run into issues the first optimization I would try is writing a script to group the tiles into chunks and hide and show chunks based on how close they are to the player.
May I ask you, how to add a collider
Good question! The easiest way is to add the collider to the ground tile prefabs you plan on using before painting with them. So for the ground tiles in my video I'd add a BoxCollider to the prefab.
@@vectorbread yieei, thnks. I will give it a shot. You are so great
Hey, thanks so much for sharing this! I have a question tho...I want the player to be able to instantiate an object (lets say a tree in your case) via clicking on the map. So in theory there should be a way to do the same "painting" thing through code right? I have however not found a solution to instantiate these Brush Objects in code. Any idea on how to go about this?
Hi Ramon! Good question and unfortunately this video won’t help in your scenario. You’ll need to a script that figures out where the user has clicked on the tilemap and instantiates the prefab at that position.
Here is an example script I made that does this:
gist.github.com/vectorbread/fac2fcacec189cded8c7cc79e8a4fa50
It works by having a collider in your scene that represents the bounds of your tilemap. When the user clicks the screen it shoots a ray and sees where it lands on the collider. Then it converts that position to the center of the cell before instantiating your prefab.
@@vectorbread Thanks! I was tinkering with the internal ObjectBrush class that is used to paint objects via the UI and even got it to work by invoking it's Paint method, but that majorly messed with the physics loop and somehow seemed to break everything.
Simply instantiating a prefab myself (at the correct position) works - thanks for the example :) The video is still super useful because I never knew you could swizzle the axis on the tilemap and that there even is the option to place real objects. That's really neat!
Thanks, Bread!
Can you also interact with the tilemap in game?
for example base building or RTS kind of games?
What kind of interaction did you have in mind? If you mean physics then you could add Colliders to the game objects you paint and your game characters could then walk on the tiles.
@@vectorbread more like placing objects in game itself just like a RTS or base builing game
@@Rubberduckerino Oh I see what you mean now! You would need a custom script to listen for the user input and then get the position on the map where to place the game object.
Here is an example script called `MapClick` which will shoot a ray where ever you click and place the prefab in the cell you clicked on.
gist.github.com/vectorbread/fac2fcacec189cded8c7cc79e8a4fa50
For it to work your ground tiles will need a collider for the ray to find.
@@vectorbread OMG thank you now I can finally make a base building game or a train game ive been thinking about thank you!
wonderful