Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How do I create a minecraft type world generator?

Discussion in 'Scripting' started by Nanior, Sep 6, 2019.

  1. Nanior

    Nanior

    Joined:
    May 4, 2019
    Posts:
    101
    Im trying to make a Mineclone, but I have got problem for generating minecraft type terrain(big but not laggy) can somebody please give a Sample?
     
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,666
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,815
    Plus probably many other similar threads, which were popping up like mushrooms after rain, over years.
    Including lead by hand YouTube tutorials.
    You can also search both Asset Store, Github and internet in general. Plenty fish to choose from.
     
  4. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,606
    Did we really need this thread after you asked the same thing in another one a couple minutes earlier?
    https://forum.unity.com/threads/minecraft-terrain-generation-help.161314/

    I told you how its done. I told you about potential problems and how to fix them. I gave you pseudo code for the general idea. And you even posted an asset youtself that does it for as little as 5 bucks. Can i conclude that you dont want to understand the topic and want a fully functional example, but dont want to spend 5 bucks on it either?
    What you are asking for is not something people will paste you in a small code example here on a forum. And for anything more than that there are literally hundreds of tutorials out there. Did you look some up? As i already mentioned in the other thread, tons of them made their code public, which seems to be what you want. So i'm not quite sure why you opened this thread, unless you literally want us to link you tutorials or code the entire thing for you?
     
    Lethn and Joe-Censored like this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    This ^^^

    What you're asking for is not a trivial code snippet someone can just whip up and post in the forum. Might as well ask on a car forum for sample instructions to build your own Ferrari knock off from scratch.
     
    Lethn and Ryiah like this.
  6. Nanior

    Nanior

    Joined:
    May 4, 2019
    Posts:
    101
    One problem is solved, but still to laggy. In minecraft the places are one model but you can still mine!:confused: Or do I need to let it only render when you see the cubes?
     
  7. Nanior

    Nanior

    Joined:
    May 4, 2019
    Posts:
    101
    And aloso I can't get on YouTube. No proxy, and I don't know any places to see tutorials!
     
  8. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,606
    No double-posting please. If you need to add something, consider using the edit function.

    As i described in my post in the other thread: for performance reasons you will have to not render individual cubes, but only the sides of cubes that are next to air, or in other words visible. You can then combine all these visible squares to one big mesh that looks like it's made up of blocks, but really is not. This is also the reason why you can see through the underground in games like minecraft, if you happen to get the camera behind terrain through some bug.
    To make the chunks editable, simply store the data in a 3-dimensional array per chunk. Each index could, for example, contain the id of the block placed there. When the player edits the chunk, for example by breaking a block, you "simply" apply that change to your array and redraw the chunk based on it.
    As you may have noticed, this requires you to draw your own cubes from squares, figure out which squares are visible (next to air), only draw necessary squares, and combine all of that into one mesh. If you can do it once, doing it again each time the player updates a chunk is no problem.
     
  9. Nanior

    Nanior

    Joined:
    May 4, 2019
    Posts:
    101
    Oh, thanks! I found it!
     
  10. Reedex

    Reedex

    Joined:
    Sep 20, 2016
    Posts:
    389
    If you have proxy issues, try different browser. I had the same issue. I couldn't get to UnityAnswers but i installed TOR or and its working.
    Or you can use greenbrowser. It has no limit to youtube videos loading so you can start 30 min video, pause in the begining and it will slowly load fully.
     
  11. Nanior

    Nanior

    Joined:
    May 4, 2019
    Posts:
    101
    What is tor?
     
  12. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,666
    https://en.wikipedia.org/wiki/Tor_(anonymity_network)

     
  13. Reedex

    Reedex

    Joined:
    Sep 20, 2016
    Posts:
    389
    In your case it would be just another browser, its based on mozilla.
     
  14. saulromerorosa

    saulromerorosa

    Joined:
    Oct 6, 2020
    Posts:
    1
    is their a free one
     
  15. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,606
    A quick search for anything with voxel and the free checkbox checked on the store leads me to the educated guess of "no". As i mentioned in my post further up tho, there is quite a bit of material on this topic online, a lot of which is open source. It's a very advanced topic tho, so i cannot really recommend it to a coding beginner. It's also one of the few topics where you will really need optimizations in order for the thing to run properly, further increasing its complexity by a lot.
     
  16. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,053
    Start here:

    Code (csharp):
    1. void Start()
    2. {
    3.   GameObject.CreatePrimitive( PrimitiveType.Cube);
    4. }
    The rest is left as an exercise to the reader... it's just like some silly code or something.