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. Dismiss Notice

Item Management Idea

Discussion in 'Scripting' started by DukeGrimm, Jul 21, 2013.

  1. DukeGrimm

    DukeGrimm

    Joined:
    Sep 29, 2012
    Posts:
    61
    I've been thinking up ways to work with item management.

    My Current idea is to create a gameobject for every item stack in the player's inventory.

    So the player character would have a blank gameObject called "Inventory". Children of Inventory would be objects stored in the player's bag. Then when working with GUI, the coding I think would query the Inventory for it's children and display the current collection of objects.

    I know gameObjects have transform and some other data baggage compared to a bare bones class. Would it be too intensive to use this sort of system for item management? Or perhaps is there some other reason that one should just use an array/lists and classes for inventory item tracking?
     
  2. foxter888

    foxter888

    Joined:
    May 3, 2010
    Posts:
    530
    yes if you are planning a inventory type system usefull things to know are classes, arrays, lists, loops, enums and the functions itself such as returning a type
     
  3. DukeGrimm

    DukeGrimm

    Joined:
    Sep 29, 2012
    Posts:
    61
    That much I knew, I what I was looking for is if there is any reason to or not to manage items via gameobjects rather than arrays of objects created from item classes.
     
  4. exiguous

    exiguous

    Joined:
    Nov 21, 2010
    Posts:
    1,749
    you should ask yourself what do you need the gameobject functionality for? when you don't need it explicitely you should not include it. simple as that.
     
  5. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Agree with @exiguous. Just do the KISS approach. If you don't need gameobject, why use it?