Search Unity

Create multiple virtual objects

Discussion in 'Getting Started' started by UrhJa, Jul 22, 2019.

  1. UrhJa

    UrhJa

    Joined:
    Dec 24, 2017
    Posts:
    2
    Hi, i'm currently developping a simple tycoon game.

    The main focus and loop of the game is creating objects.

    For example. You create a car. We have a class named "car" which includes name of the car, power etc.
    And I want player to input data through UI and store that data and then display it maybe even use it.

    My question is. What is the best way to create multiple objects that player can create in-game and store them.

    I've looking for the best possible solution for quite a while now and I would really appreciate your help.

    Thank You in advance.
     
  2. LForward1

    LForward1

    Joined:
    Jul 22, 2019
    Posts:
    10
    Bro did you find out how to do that? I will apreciateif you will share.
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    5,728
    List / Array.

    Btw. I requested move thread to
    Game Design
    But maybe is even more suitable in
    Getting Started
     
    UrhJa and GameDevCouple_I like this.
  4. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,967
    Thats a question that is pretty specific to your specific game and overall setup. Im not sure you will get a lot of in depth help. In terms of storing stuff you can create a class to hold the info about the object, including what prefab represents the in-world object (3d model / sprite of object / icon etc) and then collect all of it in a collection such as a list or array, and then pull relevant info out when you need it such as for spawning, getting stats etc.

    Thats very high level though, but it should all be relatively easy.

    EDIT: this should get you started on similar concepts:

    https://medium.com/@yonem9/create-an-unity-inventory-part-1-basic-data-model-3b54451e25ec
     
    Last edited: Jul 23, 2019
    UrhJa and Antypodish like this.
  5. UrhJa

    UrhJa

    Joined:
    Dec 24, 2017
    Posts:
    2
    Yes i did :)