Search Unity

Question How do I deal with automation game?

Discussion in 'Getting Started' started by PHOENIX33201, Sep 6, 2023.

  1. PHOENIX33201


    Apr 16, 2022
    I was thinking about making some automation game like Factorio (just much simpler).

    And I dont really know how to do that without frying my computer, because map with size of 200x200 (which is still pretty small for automation game) is 40k tiles. I am pretty sure, that having over 40k monobehaviors would obliterate any computer.

    I tought of using ECS for this purpouse, but I have no idea how to deal with multiblocks* or how to take one item from some tile and put it to other one.
    (I dont even know if using ECS for this purpouse is good idea.)

    * With multiblock I mean for example factory taking more space than one tile.
  2. AngryProgrammer


    Jun 4, 2019
    It all depends on time. But I could think about the core mechanism behind Unity and store the data you need on a 200x200 matrix build from int or long type (it's like 320kB?). You can use a mask on int or long to store multiple data. For example on the first 4 bits you have an ID of terrain type, on another 4 bits an ID of stuff you build on it, and another 4 bits an ID of action happening on it, etc. Such operations are almost instantaneous on any computer.

    The trick is to translate what going on on the core matrix to what the player sees on the screen by Unity game objects. Maybe activating only parts when the camera moves (generating on the fly)?