Random Map Generator in UNITY! [Tutorial]

Поділитися
Вставка
  • Опубліковано 29 вер 2024

КОМЕНТАРІ • 56

  • @broman6594
    @broman6594 6 місяців тому +3

    I followed your enitre tutorial ( great tutorial btw), but i have a problem when trying to start my game. when starting up my game my enitre unity freezes. I can see a small percentage of the map but nothing more. Can someone please help me fix this issue?

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

      Hi there! Thanks for commenting - glad you enjoyed! Jump into my Discord, I think it might be linked in the description and send a copy of the code if possible!

  • @Birbsters
    @Birbsters Рік тому +17

    Great tutorial! Just one suggestions maybe try increasing the overall volume next time because it's a bit quiet

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

      Thanks so much! Hope it was helpful - Shame about the audio, I tried bumping it up an extra 50% but might have to do more for the next video! Hope it wasn’t too hard to listen!

  • @420glaze2
    @420glaze2 Рік тому +5

    Ur a procedurally generated cutie

  • @cedrikgalaxy5495
    @cedrikgalaxy5495 9 місяців тому +3

    Tipp dont crop the video some things were harder to see due to them not being visible and dont cut when your going through Lists like window being able to keep track of your mouse or what you are doing in general is what makes this into a tutorial so concentrate less on speed and more on actually explaining what your doing

  • @briandeanullery
    @briandeanullery Рік тому +8

    Hey, just wanted to say nice job. I wasn't watching this for the tutorial so much as to see your approach on the subject. I thought it was cool! I'd love to see how the code could be modified to use pseudo-random numbers, so seeded maps could be generated. It was a fun watch! Short, but genuinely nice. Can't wait to see more of your videos!

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

      Hey! Thank you so much - I'm glad you found it enjoyable. I did my best to try and keep the content concise and to the point so I'm glad you liked!
      For the original prototype that I made for this project, I actually had heaps of the 'pseudo-random' variables - namely in the 'chance to change' variable, which was originally split into 3 or 4 different parts, but for the purpose of simplicity and making the video more easy to understand, I just combined them all together.
      That's actually an incredible idea though - I should definitely work on seeding the maps and being able to export the final maps in edit or run time through to a .json or similar so that map designs are reusable!

  • @kontrapunktalist
    @kontrapunktalist 3 місяці тому +1

    Good video, thanks a lot! But please normalize the volume on your video and turn down the music!!!

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

      Thank you! Glad you enjoyed - yeah I received quite a few comments on this, so I may reupload in the near future!

  • @realcolormusic
    @realcolormusic Рік тому +4

    Sorry to say, but it's very hard to listen. The music is louder than your voice. EDIT: I doesn't wanted to sound mean. What I can hear out from the sound is that your microphone does not react on your voice enough. Maybe you need to configure at which db the recording software records your speak, or bring the microfon closer to your mouth. Anyway, thanks for sharing your knowledge.

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

      I’m so sorry about that! I did have a lot of troubles with the editing software I was using when I recorded this and received a lot of comments saying similar things - More recent videos I have fixed this but I’m sorry about that! Hopefully you didn’t have too much issues understanding

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

      @@GarnetKane Sorry for my late response and thanks for your answer. Unfortunately I wasn't able to follow your tutorial until last weekend. But I am a beginner in Unity so I had to do the tutorial first. After that I wasn't sure which project I should pick (2D or 2D URP). I picked the URP project and followed the tutorial until 2:38. I downloaded the asset from your github repository but the two tiles are one? In the video they are separated and you can drag and drop the green color alone. In my case I cannot move any of them. XD

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

      Ahh solved it with this 5 year old video. xD ua-cam.com/video/ryISV_nH8qw/v-deo.html Maybe you want to re-create your video from the ground up? It is really good but hard to follow if you are a noob like me and only know Visual Studio. xD

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

      I also had to setup Visual Studio 2022 for coding because IntelliSense wasn't working. This solved the issue for me: ua-cam.com/video/5eeI2hWgPbA/v-deo.html

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

      I made it! I had some issues with the camera. Looked up, instead down. I added this to the code:
      Camera.main.transform.position = new Vector3(TileCenter.x, TileCenter.y, 1);
      Camera.main.orthographicSize = gridHandler.GetLength(0) * 2;
      Camera.main.transform.rotation = new(0, 180, 0, WaitTime);
      Thank you very much for your great tutorial!

  • @pawegorka8589
    @pawegorka8589 4 місяці тому +1

    during this video i pray to yt to give us option to mute background music someday :/

    • @GarnetKane
      @GarnetKane  3 місяці тому +1

      I'm so sorry! That was definitely my bad - I will work on reuploading with the audio fixed

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

    Hey, your vdeos are awesome! I also want to become a game developer like u. Can you suggest me what course tutorial to follow to become game developer and what advice u suggest me?

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

      Hi! Thank you so much - glad you enjoy my videos! I have made a video on how to get into Game Development - I definitely recommend checking that out. Otherwise, feel free to join my Discord (link for it in video bio) and I will be happy to chat there and point you to some relevant tutorials! :)

  • @3mocan
    @3mocan Рік тому +1

    Could you make a video about spawning random things on this map like ores, enemies, trees i couldn't make it.

  • @midaz8716
    @midaz8716 8 місяців тому +1

    Could you show us now how to make a character with an inventory that moves within this map ?

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

      Of course! This is a great suggestion - thank you. I'll definitely work on this - but if you need help real soon, if you have a discord, join my personal discord and send a message on there and I'll try and walk you through it!

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

    This is excellent, thank you. I'd like to see it expanded for platformer/metroidvania level design with start point platforms and boss room. I am enjoying playing around with this.

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

      I'm glad you enjoyed! That's a great idea - I would actually love to try this sort of concept out as a platformer/metroidvania style like Dead Cells, so I might have a crack at doing that! I'll get back to this comment if I come up with anything! Thank you :)

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

      @@GarnetKane ya might check a couple of blackthornprods procedural methods, I also built his system for room generation and it seams solid.
      At any rate I will be watching your content from hear on out, and can't wait to see more tutorials

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

    The thumbnail looks like the USA and Europe

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

      Hahaha hey good pickup! might need to change the purpose of the video now ;)

  • @MarcelQT
    @MarcelQT Рік тому +4

    Love it bro! It's awesome how understanding Object Oriented Programming concepts helps to understanding functionality across languages. I haven't used C# in years but your explanation and OOP makes it so easy to understand!

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

      Cheers bro!! And yeah, took me a while before I ever used proper OOP concepts inside of unity (MonoBehaviour and Unity Objects were just such an easy fallback and I relied on it... way too much...) but super useful both in terms of readability but also efficiency to have the more Object Oriented programming implemented!

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

      @@GarnetKane I found a kinda more advanced tutorial but one issue I found in all of them is that there are random gaps in the floor which end up causing walls to be in the middle of the room. is there a way to fix this? I thought about checking each position in the grid that's empty to see if i's surrounded by floor tiles. If there are 3 or more floor tiles it covers that area with a floor tile. Would this work or be too expensive?

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

      @@alexthompson8977 Hey! So, the algorithm can be somewhat expensive but on a larger scale for the game it's ultimately not gonna affect it enough for you to worry about. Doing those checks though the biggest problem you will probably encounter is for the edges and corner pieces of the map that might have even up to 6 or 7 neighbouring floor pieces - so by checking each grid if its empty and then checking if there are also 3+ floor tiles, it'll probably go into an endless loop or end up creating a more sort of defined country-like shape instead (essentially removing any of the 'hallway' type variations of the map that you might see)
      I'm not sure the exact approach for this, I can tinker around in my own code and see if I can find a solution, but if you are able to come up with one before I get a response out, definitely let me know in the comments - would love to see how you come up with it.

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

      @@GarnetKane oh I don't want any hallways. I just want small islands to appear one at a time(basically regenerate it whenever I enter another door).

  • @kql2118
    @kql2118 7 місяців тому +1

    hey just wondering why do you use coroutines instead of methods? anyway awesome video great explanation

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

      Hey! Great question - and completely valid, coroutines serve nothing in this purpose OTHER than the visualisation (i.e. watching the tiles get generated one at a time) - but if you swapped it to methods then it will generate immediately. i just liked how it looked watching the walkers move around but completely unnecessary if you don't need to visualise it :)

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

    Great video, But how would we go about decorating the map ?

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

      Thank you! I'll give you the suggestion just off the top of my head, but I might do a follow up video on this to make it clearer.
      In the WalkerGenerator class, create a new List of Tiles like this public List DecorationTiles; and in the inspector, populate that with decorative items (bushes, grass, sand, shrubs, etc.). Once the walls have been completed, you can make a new call to a new method called like, Decorate Floors for example, and inside of that method, depending on how many pieces you want to create you can do something like:
      void DecorateFloors(){
      for(int x = 0; x < 20; x++) //assuming '20' is the number of decorative pieces you want
      {
      int randomX = Random.Range(0, Grid.GetLength(0));
      int randomY = Random.Range(0, Grid.GetLength(1));
      tileMap.SetTile(new Vector3Int(randomX, randomY, 0), Random.Range(0, DecorationTiles.Count));
      }
      }
      Hopefully that makes sense, I will update this comment once I test it but hopefully something like this works!

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

      @@GarnetKane Thanks! I'll try to make something out of this.

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

    Thanks for you vedio.However, I have one more qustion,how can I make a more empty map,I mean I want more connections instead of a large part of the full,thanks

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

      Hi! I’m glad you enjoyed - I’m away for the next few days but I will get back to you on Monday/Tuesday with a solution!
      Thank you :)

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

    Can you use this method to place more tile types than just floor and wall?

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

      For sure! Whatever you want really - I just found it most effective with walls and floors, but with some tinkering in the algorithm you can get it super specific, corridors, islands, objects etc.!

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

    does anyone know any free tilemap images for grass and water similar to the one he uses?

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

      Hey! I recommend checking out itch.io for some! I just checked and they have heaps of free ones that are really neat. If you have any trouble, join my Discord and I'll be able to send some over to you

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

    Hi! I've been trying to add something into this script where each time it places a floor tile, there is a random chance that it also spawns an enemy on the same tile. Unfortunately every idea I've tried causes the enemies to be spawned very far outside of the map. Do you have any ideas on why that might be happening, or a solution to getting them to spawn on floor tiles? thanks in advance! subbed the second I found this tutorial :)

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

      Hey I appreciate it!
      Do you have the project on Github so I can view the code?
      Otherwise, copy the code where you’re spawning the tiles and enemies into something like PasteBin and send me the link to it and I’ll give you an answer :)

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

      hi, I made a similar code, if you are still searching for an answer a year later reply

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

    Mic up music down

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

    Tysm. and aslo can u pls tell me how i could add collision to just the walls and not the grass pls

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

      nvm,I figured it out

    • @namk0163
      @namk0163 6 місяців тому +2

      @@diamondshark4878 please tell me how u did it, ive been stuck with the same issue for weeks

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

      Hey @namk0163 - Feel free to join my discord group (should be in the channel links page) and I can assist you! I have a solution for it myself :)

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

    Awesome!!! i’m really grateful for that tutorial

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

      Thank you! Really happy I could help - Let me know if there's any other types of videos you want to see in the future :)

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

    im new to coding and i was wondering how do i get the border so water to have a hitbox they can't go through! Great tutorial!