Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

A spore like galaxy generator/explorer

Discussion in '2D' started by linevite, Feb 3, 2019.

  1. linevite

    linevite

    Joined:
    Jan 30, 2019
    Posts:
    2
    I am looking to build a game that has a similar galaxy generator to the 2008 game spore. In which a massive galaxy is randomly generated, and the player's ship can travel between different star systems.

    I want the galaxy to be generated as the player is exploring. So if the player moves into unexplored sectors, that sector is procedural generated as that is occurring, is that possible?

    I saw a few galaxy generators on the assets store and they generate the entire galaxy all at once, and I am worried if this would be unusable on a phone game due to performance? Also do these galaxy generators allow their stars to be usable objects?
     
  2. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    It's doable you just need a procedural generation system and object pooling.
     
  3. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    you'll want to 'generate' the whole system ahead of time but not actually create it until its visible. the reason for this is because if a player explores too much of the galaxy they will experience the same issues as you're saying - too many planets etc. additionally if you ever want to go multiplayer or have any sense of consistency you'll want to have the planets spawn in the same fashion/location.

    so - have a fixed way of generating planets, eg. use seed XXX and generate as new areas get explored and delete areas currently not visible
     
  4. linevite

    linevite

    Joined:
    Jan 30, 2019
    Posts:
    2
    Can you explain how to generate regions? Is there any examples on the assets store? I am just confused how to generate the galaxy one section at time

    Also, you mentioned deleting non-visible planets, can you explain that? If they are deleted then the player cannot return to those planets again and experience the same thing correct?
     
    Last edited: Feb 6, 2019
  5. TheHammer1

    TheHammer1

    Joined:
    Oct 15, 2015
    Posts:
    25
    Primoz is not saying that these areas are forever deleted, their data will be stored by the game and will still exist. The space that it takes up in the game disappears instead. When the player returns, the stored data is used to regenerate the area of the world.

    Some examples:
    http://cddawiki.chezzo.com/cdda_wiki/index.php?title=Reality_bubble
    https://minecraft.gamepedia.com/Chunk


    To generate regions, you will need to apply an algorithm. Using code, we can randomly generate random terrain that follows a "rule" implemented in the code. The code, using the rule, can order the random chaos into ordered generation. For example, I could generate terrain with varying heights. Using a rule, I could eliminate height that is unrealistic. This involves a pretty big deal o' math.

    Examples:
    http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php
    In this article, the author randomly generates rooms and then uses a rule to select rooms to be used. Keep in mind this is not Unity, but it shows the principles of random generation pretty well.