Custom Tilemap in Unity with Saving and Loading (Level Editor)

Custom Tilemap in Unity with Saving and Loading (Level Editor)

Code Monkey

4 года назад

73,219 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Quang Nguyen
Quang Nguyen - 17.09.2023 13:04

Thank you as for your tutorial.
I have a question. How does this save load system work with assets? Like sprite, sound, prefab,...
For example, I want to save and load sprite at each grid position, and when I save sprite, in the file it writes:
"sprite":{"instanceID":29168}
I am able to save and load normally. But I want to know if it's still the same when I build and run game in other devices? And does it apply to other assets as well?

Ответить
Tomas Gammister
Tomas Gammister - 04.07.2023 19:49

I am tormented by vague doubts))) 😆 now I will try )

Ответить
Tomas Gammister
Tomas Gammister - 04.07.2023 12:48

and it will work like saving the level and the game itself with loading the game back?

Ответить
Евгений Гринчак
Евгений Гринчак - 09.06.2023 23:02

Hi @CodeMonkeyUnity!
Can you please give some advice - how to get array of gridNode objects that you creating in test script?

Or may be is exist different metod to get coordinates of all gridNode objects with isWalkable false value?

Ответить
鄭閎文
鄭閎文 - 08.05.2023 22:46

I LOVE YOU

Ответить
MANFLU
MANFLU - 29.03.2023 16:50

Hi, I can't figure out how to this to work in a 3D environment / along the z axis and not the y? When I try to fiddle with the MeshUtils I can't get it to work. When I just use your code as is, then all the vertices "stand upright" but along the x and y axis.
I have tried looking through your 2d to 3d video, Mesh and Grid Building (and through your project files) but I can't find a solution.

Ответить
Felix
Felix - 14.02.2023 14:30

Just want to say: thanks for all the amazing videos!
Took me a bit of tinkering to get everything right but that thought me so much more than any of the superficial yt videos other creators put out!
Really love the fact that you don't use the unity standard functions for everything bc those are really limited when it comes to making something truly custom.

One question though: currently the enum is implemented in the tilemap object and is then serialized in the tilemap visual. what would you suggest to do for multiple tilemap sets (i.e.: ground, props, walls etc)? create a custom tilemap object for each and everyone? Or forego the specific naming altogether and just name the enums after quadrants of same sized materials? Would rly appreciate your input on this!

Ответить
Piotr Bugno
Piotr Bugno - 22.01.2023 14:59

Thanks!

Ответить
Laim
Laim - 19.01.2023 20:29

Would there be a reasonably ... "simple"? way of building colliders into this to prevent players going through walls? You might already have a video on it but I couldn't find anything

Ответить
77eight8
77eight8 - 14.01.2023 02:18

Hello Code Monkey! I have a question. How do we convert this for a hex grid like in the latest videos? I tried to use this for my hex grid but the tilemap is not created correctly. Thanks in advance and have a nice day!

Ответить
Shawn Ray
Shawn Ray - 29.10.2022 05:37

So I think I’m going to use scriptable object to make a 3D dungeon. This should work pretty well as long as I don’t try to overlap pieces. The scriptable object will just save the prefab and height.

Ответить
Tst Kenny
Tst Kenny - 07.10.2022 05:18

Could anyone share a working version of the .cs files or the project by a git repo? I am pretty sure that many visitors are unable to make it work after hours of researching... thank you!

Ответить
Glyphic Enigma
Glyphic Enigma - 07.10.2022 03:55

My visual grid has huge gaps in between each cell but my code is exactly how it is in the video. How do I fix this????

Ответить
Casey Strong
Casey Strong - 18.09.2022 15:29

It's not shown in the video, but towards the end of adding saving and loading, you also need to add the Tilemap parameter to the calling of the SetGrid function.
It threw me off I didn't see it mentioned in the video, so I went back and rewatched it because I thought I missed something.

Ответить
heyitsapogee
heyitsapogee - 16.06.2022 18:24

Hey Code Monkey - I'm interested to hear how you'd implement collisions into the tilemap? What if you were creating these tilemaps for players to explore and didnt want them running through wall tiles?

Ответить
毛豆綠
毛豆綠 - 24.03.2022 04:25

I started following your channel and learned a lot of things I didn't know before. Thanks for all the detailed explanation which helps me to make my codes cleaner and easier to use.

I used to hard code all the logic and waste tons of time on unnecessary places, and now I start to use generic class and namespace to store methods that can be reused in other projects, plus some cool system features I learned from you.

It's great to find an awesome mentor like you on the internet.

Ответить
Anthony
Anthony - 27.12.2021 00:48

With any grid above 100*100 my width is staying stuck at 100 and height increasing only it seems. The mesh starts to look all distorted... any idea? Is this something like max vertices in a single mesh? I would have to create multiple mesh' at this point?

Ответить
Developer Jake
Developer Jake - 26.12.2021 13:51

you’re an amazing person

Ответить
MrJimmyAinsley
MrJimmyAinsley - 04.11.2021 15:24

I added the MeshUtils and followed everything but somehow all I get are a few yellow lines that are drawn over my grid randomly, I can't get the color from the black red yellow green texture to be applied in the grid, it's all transparent with None/Ground, and then those weird yellow lines. Any idea what I'm missing?

Ответить
Anthony
Anthony - 26.10.2021 07:19

I've been following your great tutorials around the grid system & pathfinding, thank you so much for these tutorials! This is my next hurdle.
My first question is should I make another grid entirely for this tilemap, or edit the PathNode object to include the sprite stuff and just have one grid of objects?
Second question: I have my tilesets set out seperate for grass, dirt, water, with corners, sides, etc for each, I've imported them using normal unity tilemap and cutting them out with multiple on sprite editor and painting a scene just for testing purposes. But whats the best way to use these or turn them into what you've done? Should I have all water/grass/dirt on one big mesh renderer thing and use a vector to select which one? Is there a smart way to group them by grass/dirt/etc?

Ответить
Patrick
Patrick - 17.10.2021 17:20

Hey Monke, is there any chance of getting this to work with tilemap chunks and auto-tiling?

Ответить
Raimon Johvallius
Raimon Johvallius - 27.09.2021 09:55

Why o why would you have so many classes inside of other classes? Its bad practise to have a class within a class

Ответить
Nicholas Pitti
Nicholas Pitti - 01.09.2021 21:33

Hey CM do you reccomend using this grid system for inventory and quick item slots? Or should I just use the other tutorial you made?

Ответить
Александр Alexander
Александр Alexander - 26.08.2021 02:03

hello/ i imported the Project files and Utilities from package in link, and when i run the game i just see gray screen. Can you help me? what can be a problem?

Ответить
Ben Shaw
Ben Shaw - 01.08.2021 16:53

Dude slow down, wtf

Ответить
Dumitru Iordachi
Dumitru Iordachi - 18.07.2021 15:00

It is possible to do in 3d?

Ответить
david zaslavsky
david zaslavsky - 08.05.2021 01:18

hey small problem when I click on the square its not changing from none to ground
the part that it is not working is the SetTilemapSprite
update fixed it

Ответить
Marethos.
Marethos. - 28.03.2021 23:40

Hello CM!
I was wondering if you could help me out.
I am currently trying to do this Tutorial, but some things just dont want to work sadly.
Following the tutorial step by step (Using your Grid system implemented in another video) i get an Error:
"The non-generic type 'Grid' cannot be used with type arguments"
This is spat out for multiple lines.
Even if I copy your script from the UnityPackage provided for download (awesome btw!), it does not work.

Trying to see if i have done something wrong i tried the "GameScene_Tilemap" which is in the tilemap assets folder where everything seems to be set up. Sadly the GameHandler and other Objects are missing Scripts.

Since there is no README included i want to ask you if you know of a possible solution for this project. I really love the idea and would love to get it working.

Keep up the great work CM!

Ответить
Luka
Luka - 27.03.2021 02:35

Someone has a clue about how to use this system with a Tileset? because this system is a little bit hard to use with 2d games with a side look :(

Ответить
BrokenPuzzle
BrokenPuzzle - 26.03.2021 04:12

When you create the constructor for the tilemap on the function part you send as a parameter grid. when it should be g.
Just letting other know since it took me a while to figure out.

Ответить
Brian Jensen
Brian Jensen - 25.03.2021 14:27

I don't like the packaging of the Util class with everything in every project. Tons of useless junk in packages. Also the Utils class is just a nice way to hide the fact Camera.main is used everywhere. This is not code you should use. Nor should you hide it in such a manner. Shame on you.

Ответить
Paritosh Mishra
Paritosh Mishra - 16.03.2021 13:39

My tilemap cells are larger in size in compare to grid cells size. Any idea why that happens.

Ответить
dragon lord
dragon lord - 11.02.2021 22:04

Hey, I just wanted to know if there any significant performance differences between your tilemap system VS Unity's built-in tilemap. I'm thinking about digging into some large scale procedural generation and this system seems practically perfect for that, but at the same time, I want to know if there's a significant performance difference between the two because then I'll have to choose the built-in system instead to decrease the performance hit (even though jerry rigging procedural tile generation in the built-in will be more difficult in the short term). Which do you think will be better from an optimization perspective? This or built-in?

Ответить
It's Mii
It's Mii - 24.01.2021 23:23

Hello, I tried making the tilemap account for variable tile sizes, and therefore render the quads at different sizes, but it leads to overlaying quads. Is there a way to control the rendering order of individual quads? I tried sorting them by the Z axis and also by flipping the order in which they're updated, but nothing seems to work. As it stands right now tiles higher on the y axis always render in front. Thank you for all hypothetical responses!

Ответить
General MD
General MD - 07.12.2020 06:19

How can I use it isometrically?

Ответить
HydraOrc's Games
HydraOrc's Games - 12.10.2020 13:02

I don't understand how do you make your tilemapvisual to be visible in play mode? I added the scripts and the visuals but still cannot see the black grid that you have in your video

Ответить
jello hunter7
jello hunter7 - 07.10.2020 02:56

Is there a reason you would use this over unity's built-in tilemap system?

Ответить
MaviEkran
MaviEkran - 05.10.2020 16:33

How can i do this with job system ?

Ответить
Collin Farrell
Collin Farrell - 01.10.2020 19:00

Has anyone found a solution they like for determining and updating the transitions between different tilemap types, such as corners and edges of dirt up against path or grass tiles etc?

Ответить