Godot 4 GridMap Tutorial - TileMaps, but 3D
HTML-код
- Опубликовано: 21 окт 2024
- In this Godot 4.1.1 tutorial video I talk about how we can use grid maps in order to create fast levels. I discuss everything you need in order to start using GridMaps, including MeshLibraries, how to navigate the GridMap interface, and tips and tricks to avoid common issues when using them. Gridmaps are an important tool in Godot level design because they let you use the benefits of multimeshes without having to write code.
Support the channel: / legiongames
Discord: / discord
Itch: legiongames.it...
Twitter: / legiongames1
Instagram: / legiongames1
Assets:
Water: godotshaders.c...
Meshes: kenney.nl/asse...
1:40 if you press shift+f you go on free view mode
You just saved my life for my next project, thank you.
@@legiongames2400 how do I give all of the tiles collisions?, I want to make it so my player can walk on it.
@@breadman6666 literally explained at the last minute or two of the video...
@@Khunkurisu i am going insane :)
you sir are a scholar.
Perhaps my favorite Godot video so far... It's quick, to the point, and just saved me a crapload of time. Thank you so much.
For anyone using Kenny assets (or something similar) where you follow along but can't get any meshes to show up in the library resource:
Use the OBJ format instead of the GLTF
Instead of adding all of them as a child directly to the node, drag them all at once into the editor and they'll get added as a mesh
Select them all in the scene tree and reset their transform
Export as normal
I hope this helped someone, because it took me about an hour to figure out lol
tried in 2 different computers (1 win 1 steam deck) cannot get it, thank you
Thank you!
tip: make the mesh library in one blender and glb file, godot will recognize the separate meshes and makes it really easy to generate collision shapes
I was apprehensive about watching these tutorial videos but I love you for finally showing me how to fill. I managed to find shift + f for freecam on my own, but great to see others told you about it too.
Really feels like there should be an easier place for all this information as it makes gridmaps feel incomplete when really all the things you need are secretly there somewhere.
Pretty much the nature of on open source project like this. :( Stuff gets added but the documentation lags behind sometimes.
FYI, you can layer the gridmaps. So say you want a wall, but you also want extra stuff from the same tileset on it. Make another gridmap and boom you can stack it.
Thank you
Deselect *Merge With Existing* option when exporting to overwrite - otherwise it will merge the libraries creating duplicate meshes for the meshes that were updated.
wow this is amazing. so much information is being shot at me as fast as possible
You're welcome
Question: isn't this horrible for performance since most of the faces are inside the level? There doesn't appear to be any face culling system.
Belated reply but you can export a 3d scene in godot as a gltf file. Which you can then import with blender or maya and modify. So once you lay out your level you can clean up interior faces and make it performant.
That's a great point I didn't think about. Cleaning up a full level / world area in Blender after this sounds like a huge pain, unless maybe you were able to pull it off quickly using a boolean modifier or something, but I have no idea.
Grid maps need a LOT of work before they are useful, right now it feels like they are more of a lesson in perseverance than useful. Here is hoping they improve this feature in the future!
maybe im just late to the party but why is it not useful? I found it very useful to generating a procedural 3d maze
im trying to use it and its so damn inconvenient i almost went to 2d. you cannot move freely in this mode, initially transform wasnt being set but i discovered you have to set the transfrom with "ctrl + a" in blender, you cant delete all objects in the world - what if i mistankly put an important object very far from the map? terrible experience
cool video format, short ant straight to the point. Great stuff.
Yeah these are fun to make :) A bit more short and fun. Thank you for watching!
Great stuff. Would you fulfill these requests?
-How to make an interactable door/window.
-How to add those doors/windows to an already existing walls.
1. make an area scene that you can instantiate it in the level scene, write a code in it that exports the target as a node (door/window/anything), add a boolean for being open or closed, and give it a signal so it can trigger the animation player inside the door/window scene. now drag the area into the scene, either make a raycast to collide with the area or write the code if a body entered the area and basically that's it
2. 3d modeling software
how economical is it in terms of performance? because some polygons of tiles overlap each other on the side, except for those that are located on the edge
Not very
Hey, can you post the project or full environment settings to recreate your scene? I tried playing with the values you show in the video but it doesn't come close to how nice your scene looks!
I considered leaving a like and i hope to see you back with tutorials like this (can be a bit longer so you can monetize a bit more if possible ^^ )
From a beginners perspective. I love this.
thanks for the tutorial I've started learning more game development because I'm bored of making websites. It sounded like you were frustrated in this video. Is there something frustrating about grid maps that nobody talks about? Kind of confused after getting mixed messages. Cheers anyway
Best godot tutorials. U Garbaj and Lucky are a life save
Thank you friend! :) That means a lot
@@legiongames2400 would you be interested in going over how to make this project multiplayer? My game im making is multiplayer and there are so few good godot multiplayer tutorials. Especially for 4!
Quick Straight to the Point Perfect... thanks
Thank you!
Great tutorial.It was extremely helpful. I didn't quite catch how you stacked the items in layers.
If you look at 1:00 and watch the top, it shows the floor level he is working on.
A question I have is tesselation. When you place a bunch of tiles together, is there still the hidden geometry inside of the sides, edges and stuff or does the program automatically remove unecessary geometry?
Otherwise it may be wiser to design tile maps with and without sides so you can have a mid section and edge section etc for optimisation.
Thank you for watching! Nop, geometry is still there. It is indeed better to have just corner tiles for optimization.
Thanks for the video @@legiongames2400! I was wondering the same thing as @DynoStorm and it'd be cool if you could give a follow-up video to this with some of these tips.
how did u create a water?
Hey, thank you for this simple tutorial. Got one problem with lighting not affecting the gridmap, I mean when I change light settings on the World Environment the tiles of the GridMap are not affected at all by the light. Do you have any hint about it? I'm using forward+ and the same kenney assets as you do. Btw, the water (using the same shader as you) is affected by light settings.
thank you so much bro, your an actual life saver for real
I have got several questions:
-Is this well optimized? Does either the geometry or the collision points get merged or they are separate objects?
-How can I make sure I made the right size? I'm using blender, how do blender units translate to these godot units?
Is it possible to include Area3D nodes into the base tiles, so that when you place tiles, you place all the functionality thats included?
For example, I have a mesh library made up of floor tile scenes.
All of them are basic:
Node3D
->Node3D_Name
-->MeshInstance3D
--->StaticBody3D
----->CollisionShape3D
However, I have one that is:
Node3D
->Node3D_Name
-->MeshInstance3D
--->StaticBody3D
----->CollisionShape3D
->Area3d
-->CollisionShape3D
When I place this special tile with the Area3D included, the Area3D Collisionshape doesn't show up on the Gridmap.
Is there a way to include this? Or do I have to manually place the area3D's separately to my gridmap?
big help ty. Pls keep making more videos
Thank you friend! :) Bet.
Hey I have a question I'm making a fps video game and your tutorials are useful and could you tell me what you plan to record in a month?
At least a tut on ranged enemies, not sure after that.
I tried to follow along, but for some reason I couldn't change the albedo when I got up to that part, decided to just keep going, then for some reason after adding the static body I magically could edit albedo.
Tried with other meshes and cant edit albedo. Add static body or collision shape, suddenly can edit, but it's odd and finicky. No idea what's going on there, but nice video.
Extra: After some fiddling about, and watching that bit again. I think it's because you need to save after making the mesh local before you can edit. I notice at 2:18 you have the unsaved project star, and then at 2:19 it's gone. Dunno if that was a smooth cut, or you pressed a keyboard shortcut or something, but either way it doesn't appear to have anything to do with adding nodes, and just needs to be saved. Mystery solved
A little janky, I'm not gonna lie. But I'm glad you figured it out.
Hey bro, I hope you are doing well today, I like to know which courses do you study to learn this 😊
For those wondering, You can move around in the GridMap using Shift + MouseWheel
Great video! I have one question - I have 2 tiles in my tileset, grass and a bench. When I try to place the bench tile on top of the grass tile (the way you did with the arrows) the bench tile replaces the grass - which leaves it with just blank space underneath the bench where the grass was. I don't think it allows me to place multiple tiles in one spot. How did you get that to work with the arrows?
Use 2 gridmaps.
@TheTownPortal in the video he's only using 1, how do you set it up like that?
@@ColtonCrawford Just add multiple gridmaps... 1 named "buildings" 1 named "details" and so on... i use multiple gridmaps, all with different "types" of objects, easier to toggle on/off also, if needed.
@TheTownPortal I understand that that is an option, I'm just wondering how he set it up in the video to act the way he has it. If I can consolidate 6 or 7 gridmaps down to one I'd like to know how
@@ColtonCrawford you have the floor option at 1:00
I love the tutorial! Is there anyway I can add new tiles later or do I have to make the tile set all at once?
Yeah you can add tiles to the scene you exported later and then just export it again. Just make sure to add them at the bottom of the tree because the gridmap keeps track of the tiles you placed depending on their order in the exported scene.
More... I need more of this!. Love it. Thanks. Sub and Liked
there was no tiles available to place in the GridMap after adding the .tres, any ideas?
Great video, thanks! Should collision also work with CharacterBody3D? Because I’ve set the collision object and it’s working when I use normal objects but not on grid mad :/
Yeah it should work as long as you have a static body and a collision shape inside of each mesh
Okay but how do I generate a pre made room using tiles randomly?
I have been searching though a lot of youtube videos coming out empty handed as you cannot make a mess library out of the tiles you made to make a room with it.
As in if you have a room made up of tiles I want to take that room and generate it randomly on a map with other pre made rooms on my map.
Depends on what your goal is.
Something you should know is that you can save a GridMap as a Scene, so I would do something on the lines of:
1. Have a "Level" or "Overworld" GridMap, where your game will be
1. Make a "Generated Room" scene where you do all the random generation (allocating random meshes to random cells, with a custom algorithm, yada yada)
3. Istantiate "Generated Rooms" gridmaps in your Level scene
Also to Elevate Floors its
CTRL + Scrollwheel
Using Godot 4.2.1 I followed your steps exactly and even used Kenney assets. I could not get the mesh library to show ANY tiles at all. One of the work arounds I found, was to import the glb into blend, then merge the two or more meshes together into one, save as a .blend file, then instantiate the .blend, make it local, and drag the meshes out of the node. THEN it works. Very tedious.
The collision is not working why?
Can i ask if gridmaps tank fps? Im using a low end computer, and its to old to run blender.
i added many times on the mesh library buuuut it shows only the last item on the grid map , please can u help me to fix it
Some meshes when you import them have a lot of nested Node3Ds in Godot, could you try cleaning up the tree structure so that there's only meshes in the scene you're exporting into a mesh library?
could I somehow instead, import a vox file aka vox object that is made out of small cubes, creating a shape and add a gridmap this way?
I did everything as you said, but there are no models in my library.
I looked at the .tres file and there was no information about any of the resources I added. This is fine?
The scene that you're exporting into a mesh library, what kind of structure does it have? To be safe get rid of all of the Node3Ds in there and just keep the meshes in there.
@@legiongames2400 As it turned out, it is impossible to use models with several meshes. Your model must consist of one mesh for everything to work correctly. I had to spend a long time and tediously combining my models so that they would have a single mesh.
I am really struggling with properly importing Kenney's city kit roads asset package. I am able to create the MeshLibrary and GripMap but then everything is 0.25 units too high...
colision doesnt work in my proyect
Any video about how to make tiles for a gridmap like you did in this video? I suck at Blender but I want to get better by watching people like you. Pretty please?
I didn't make the tiles, they're free assets from kenney.nl/
Mr. Kenney, I loved your city builder template, thanks for your work and kindness in sharing so much!
just wow thank you.
Great video, how would I make a 3d game like metroid dread in godot ?
I have a problem when i drag the tiles.tres file into the mesh library they wont show up in the box to the right
I mean left
@@GuardianDogGDI have the same issue, let me know if you figure it out
@@UntitledToaster Ok i still haven't
Hey I'm a Godot noob, how do I download/use the water shader? I checked the link in the description and I did find the code, even created a shader material and pasted the code but I get an error as it doesn't include shader inputs when doing it that way. I wasn't familiar with shaders before this so have no idea how this works. I'll keep looking around after writing this comment tho.
EDIT: Seems I copied the wrong code, I just copied the one you put out instead but there's still an error which starts at the very first line. "error(8): Expected valid type hint after ':'."
EDIT 2: I found another similar shader and it worked fine.
Can you the same but on the Y axis, like making walls?
Can we add scripts to certain tiles? Like when one steps onto a tile, something happens?
Unfortunately not
can all those individual meshes have textures applied? In your example it is vertex paint or smth?
Yeah you can change the texture of the mesh through the material setting in the gridmap
can you use custom scenes as tiles?
Do we have to put collision separately on all different type of mesh?
Hi thank you for watching! Unfortunately, yes.
does it also work with destructible tiles? can it work if each tile is saved as .tscn ? or mesh only?
Thank you for watching. You can definitely figure out the tile in a specific position and replace it with an empty block with some calculations, yeah. It would work if each file is saved as a .tscn but it will get rid of anything that's not a mesh, collision shape, or navigation when it exports the mesh library.
thanks so much
Thank you for watching friend! :)
Not working. You didn't explain much. How do I exactly have to position the meshes inside the meshlibrary? You said it doesn't matter but when I'm placing the assets it's not placing anything, it's empty.
thanks you
thank you for the tutorial this help me a lot, can you also make a interactive tutorial like grabbing stuff like a flashlight and light switch for the light bulb or papers to pick up too, your RUclips video helps me a lot with this interaction I'm closing on finishing my horror game thank you very much!!!!
Thank you for watching friend! :) There's definitely going to be interactable objects for the fps series!
Really great video! Thanks
Thank you for watching! :)
Eggcelent!
tried this but it didt work at all just shows one tile for me to use instead of 6
haha, hi 👋 thanks for the videos!
Thank you for watching them! :)
All your videos are such high quality. I learned so much from you. Thank you.
I'm glad you're enjoying them! Thank you friend! :)
With a gridmap, is it possible to place a scene instead of a simple 3d block?
yes, you also can place tscn scene as long it has mesh node
@@ElBuhoStudiothank you
I know this video isn't specifically about this but .. Icouldn't get the water shader to work :C I copied and pasted it into the shader code bit, but it threw out an error on line 8 about ... hint or something
when i'm making plane in meshlibrary it's rotated in gridmap
Where did you find theese axe and grass and more?
Kenney assets!
Hi thats is cool video but can you make video about grappling hook?
Could you do a tutorial on how to make bullets travel to mouse position from a top down camera perspective in 3D? I don't understand how to get mouse position and have bullets go up or downhill for example if your mouse is at a higher or lower point than the player
I'm new to Godot, but in game dev in general you want to cast a ray from the click location in screenspace, down along the view normal of the camera, and find where it intersects with your terrain. Most game engines will have some built in raycasting methods that will return an array of collisions for each place the ray intersects a mesh. The best bet is to have a debug mesh that gets drawn at the intersect, so you can visualise the location
does this have performance issues? like, is there occlusion culling, or is it just all the faces rendered still?
Sorry for asking dumb questions, great tutorial btw :D
There is octant based culling and rendering, the default octant size is 8 which means that cells are split into 8x8x8 chunks and one is visible then all are rendered. Since gridmaps use multimeshes for optimization it's technically cheaper to draw those blocks in a gridmap than to draw them separately but that probably means that a very vertical level could potentially have some performance issues. See this for more info: forum.godotengine.org/t/how-to-improve-gridmap-performance-octant-size/27204
@@legiongames2400 thank you sir
Godot needs to become overwrite friendly for gridmaps and 3d animations. I reimport a 3d model I made in blender w more animations and it ignores it, I have to reimport from scratch. Very annoying, surely wouldn't be too tricky to implement.
Completely agree, it's super slow to do some of the stuff that could be solved with a simple overwrite. One thing I've found with animations is that it's better to just open up the file with the new animations you're trying to import and just copy paste the keyframes into a new animation in the old scene. Idk if that's viable in your case at all.
Dude, you just saved me a decade
How do you know what size to set your tiles? It looks like you have tiles with differing sizes
Can you set sizes for individual tiles
No you can't unfortunately, Ideally you want to clump tiles of similar sizes into different gridmaps. So you could have a ground gridmap and a decoration gridmap.
thanks so much for responding. that is quite unfortunate.@@legiongames2400
how did you do the water mesh?
godotshaders.com/shader/wind-waker-2d-water-shader-godot-4/
I followed along and everything looks alright until I actually place objects, then they appear completely black. Any suggestions why that might be, anyone? I'm on 4.1 using Compatibility mode.
same
@@chispidog7832 I figured it out, if you still (or anyone else) has the same issue - go into the Material of an object -> Vertex Color -> uncheck 'Use as Albedo'. That's it! Resave the tile scene/mesh library, and you're good to go.
If this is 'baked in' so you can't uncheck it, you should be able to override the material by making a new one/placing one on top of the existing one.
@@thisyoutubeishaunted thanks!
Great video mate, very helpfull!! Does anyone happen to know why this does not work with the Kenny Tower Defense Kit gld files? The tiles dont show up at all not just the thumbnails in the Grid map window after importing the .tres, .meshlib files. It works fine using the Kenny pack given in the decsription.
Interesting, I haven't tried it with that one. Maybe has something to do with the node structure on the imported files. You could try cleaning it up and make sure it's only meshes in there and not node3ds.
But what if I wanted to make one that’s procedurally generated?
Figure out where you want to place the blocks and use the set_cell_item function from the gridmap to place them once you have your algorithm
version 4.2 Ive been able to over write meshes with no problems.
I follow each step exactly but when I drag the tiles.tres into the meshlibrary resource I dont see any tiles
I had the same problem but fixed it by right-clicking the imported glb files in the scene to "make local" then reparenting the actual mesh nodes to the parent node.
@@RandomGuyyy Thank you so much, you have no idea how many hours I spent trying to figure it out!!
on "compatibility" renderer, godot wont load my texture :(
I was having a lot of trouble with my character falling through the block platform I made with a GridMap. It took a long time of messing around with things but it turned out that I needed to set my array size to at least 2 for that item in the meshlibrary. Hope this helps someone else.
Awesome vidéo, I'm almost there, it just seems that when I save the mesh library and then import it in the gridmap, only the last mesh is recognized as a bloc ! I can't have all the other meshes available sadly :c
i have the same problem, funny how he loves your comment but doesn't answer😂
@@kisihvalur Damn ! I ended up with a solution with a lot tweaking back in the days, but I can't remember, I'll tell you if I have the time to re check this old project. But tbh I opted for an other solution for my final project but its less beginner friendly (I basically coded a world editor for placing the nodes I created and read the "world" tree later in the game).
@@ragebbop7130 I just found a solution, the meshes need to be child of the root node. They need to be the base or the foundation.
none of the tiles show up when i export as a library and import the library into a gridmap
What's the node structure of your mesh library scene? What nodes do you have in it?
@@legiongames2400
something like this
Root
StaticBody
Mesh
Collision
StaticBody
Mesh
Collision
StaticBody
Mesh
Collision
@@PenguinGuy17 Can you try switching it up to
Root
Mesh
StaticBody
Collision
Mesh
StaticBocy
Collision
Mesh
StaticBody
Collision
@@legiongames2400 oh that fixed it, thank you! thats kinda weird lol but if it works, it works. thanks again!
when i try to add a fence, the ground gets deleted ? :/
Hey so only one object can be in one tile at a time. try splitting up your fence and your ground into different gridmaps
Breath?
why the collider wont work ?
You added static bodies with collision shapes and the collisions still wont work?
does it just copy the model or does it do something more to it? seems horribly inefficient if it just copies the model.
Copies it. You can get rid of the original file for when you're shipping the game so I don't think it matters if the data is in separate files or clumped in a mesh library.
@@legiongames2400 I am talking about mesh/geometry. Not files. In map like in your example, are you expected to have all the overlaping tiles have their full mesh or does it cull the hiden vertices/faces properly?
@@otso648 Gridmaps work by creating multimeshes depending on your octant size setting (8x8x8 in this case). If you enable occlusion culling it culls on a per-multimesh basis so no, not all the hidden faces are culled.
MeshLibrary Import seems to be broken at the moment
Can you make a tutorial on adding hands to your fps game
Eventually, yes. For now it's ranged enemies next. :D Thank you for watching!
I'm So Fucking Grateful
Strong emotions. :D Thank you for watching friend! :)
I like your tutorials but I do feel that you rush passed too many things such as in the beginning where you just casually already have the water shader and world environment setup.
I disagree. This is to the point and not wasting our time explaining how to download and install Godot. If you want to learn about environment and water shader, find another tutorial.
It's not a water shader tutorial
You should just ask for a water shader tutorial
I would say that these tutorials aren't for beginners. These are for those people who have crossed beginner level and understand many things and can learn these things easily.I also learned this easily from this tutorial though.
Did you win the race?
I recommend to create a tutorial how to add like a radio it is a thing and when you walk far you can't hear radio and you can switch the melodies, something like this would be amazing to create
Are you saying "library"?
omg this is too fast, but thanks
unfortunately is completely wasted and useless tool. If you want change anything, like changing the collision or add/remove a mesh from your gridmap, you have to delete your grid map and rebuild everything
Don't have to rebuild everything. As long as the indices of the tiles are the same you can remove the mesh library resource and re-add it and it will be the same.