Search Unity

Need Advice About an Inventory system

Discussion in 'Game Design' started by buckius82, Jul 22, 2015.

  1. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    I am not sure how to handle picking up items.

    currently i have a vision each inventory instances an empty box in the scene for the player when items are picked up via a PickUpItem method in the inventory script;
    // you right click on item in the scene
    // char moves to item
    // at destination char picks it up
    // in the method
    ** check if the item is stackable if it is add its count to the count of the item in the inventory and destroy the world model;

    ** if its not stackable send it to the box turn off its render set it as a child of the box; add it to the inventory master list so its visible in the inventory window;

    ** dropping is handled by removing the parent change its position to the characters

    ** activate the tenderer for the world object visible in the scenes,

    ** for containers just set the the items parent as the container zero its position make sure the render is off, add it to the inventory script attached to the container

    i have everything up to containers, currently working;
    i am making a team based strategy in a post apoc setting;
    were you have control of up to about 8 survivors in 1 to 3 teams at a time;

    i am worried about having to may duplicate gameobjects in the scene that slow it down;
    weapons have durability and modification values that will require them to be unique in the inventory window;

    is there a better way?
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Will you have the inventory specific to each survivor or is it a pooled inventory that all survivors have access to?
     
  3. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    How can you simplify it? If flow is the reason we play games, then simplicity is the essence of Bushnell's law, "Easy to learn, difficult to master." I hear 1-3 teams, with up to 8 survivors each, who each have an inventory. I am trying to imagine the user guiding an individual character to pick-up an item. And then, I am comparing that to the simplicity of the hundreds of GOOD RPGs I've played. /shiver.

    SIMPLIFY - SIMPLIFY - SIMPLIFY

    Examples: One combined inventory. Auto-pickup. Less characters/survivors. Less teams. Less item drops (can drop cash instead).

    Gigi
     
  4. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    Ted yes each each survivor has its own inventory; the inventory has a weight limit based on the survivors stats; strength and endurance, bags also increase the max carry slots. when i hit "i" button the currently selected survivors inventory opens; timescale is set to "0"
    in the case multiple survivors are selected [0] 's in the list is opened in the inventory window next to the selected inventory i will have a list of "containers in range" to facilitate trading items between survivors and stockpiles benches and just dropping it;
    it also adds "Survivors in range ", for trading between survivors;

    this mechanic is facilitated by doing an overlapping sphere Cast from the currently selected out to a range , for only objects that are in a layer mask associated with containers, and units thus far.

    GiGi DeadSurvivors drop from the units layer to the containers layer so you can strip your enemies and survivors; Dead survivors are dead no "Phoenix-down" here group size is going to depend on the groups Level kinda like when you level corporate management in eve online. team size is based on the teamleaders level of leadership;

    I see what your saying about simplifying i thought about shared inventory; but determined that individual inventory would up the stakes and increase the "oh-no" factor when a zombie mauls the survivor carrying the quest item or necessary build material;
    you'll have to go back and either loot the body or possibly kill the reanimated corpse of the team member and then loot its body;

    what i came up with is;
    all inventories and containers reference the itemdatabase;
    if you pick up a consumable it checks if you have a reference to the item in the itemdatabase if you do it just increases the a count list;
    if the inventory list does not contain a reference to the item in the itemdatabase it adds the reference and increases the count ;

    when i add durability to the items i will add another list to the inventory containing a durability float value 0 to 1; representing the percent of durability;

    so inventory will be parallel lists;
    the items name<string>; its reference in the database<item>; its count<int>; durability value<float>
    if items are dropped into world space we instance a new gameobject at the position of the inventory;
    reduce its count by the drop value in the instance of a consumable item and add the drop value to item component attached to the gameobject ; else we set the reference to null, the name
    = "", count = 0, durability = 0f;

    when i am complete and can move items full circle i will post a demonstration video;
     
  5. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    So it's a turn based game a bit like xcom where each character has inventory that is kitted out & can be swapped? Check how they did it & others like it, they worked well.....but, a game with up to 8 characters to manage will get complicated, especially if you get to the end & find you forgot to/wasn't able to strip a dead survivor (fell off a cliff, exploded etc) & therefore don't have the quest item.
     
  6. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    I have been messing with time scale; the game has 2 phases by pressing tab you set the timescale to 0.0f and then to 1.0f
    at time scale the user will be able to issue order to the survivor.

    as for loosing items you bring up a great point i'll have to consider it i think i may take the inventory on the dead survivor place it in a generic bag inventory and move it to the nearest point on the navigation mesh;
     
  7. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Have you given this to people to play? As in hand them the game, without explaining, to see what they do. This idea raises like 20 red flags in my head. It just SCREAMS to me that people won't enjoy how this aspects plays as much as you will enjoy building it. Something to consider.

    Gigi
     
  8. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You've posted in game design. This forum is for questions like why should I have inventory. How large should inventory be. How do I manage inventory. Your OP sounds more like a scripting question. If you are to the stage of asking how do I implement the inventory you belong in the scripting session.

    Now back to design. Inventory management is a pain in most games. In some RPGs you are constantly stopping play to dump junk items, or to rearrange. Now you are proposing to multiply that out across eight characters managed in real time.

    There are a couple of examples I've seen that worked out okay. WarCraft 3 limited you I managing an inventory of 6 items across at most three characters.

    Dawn of War did individual item carrying. But it was managed at the squad level. So you didn't assign items to individuals, rather to the squad. The AI sorted out detailed assignments.

    The only way I could see complex multi character inventories working is if you build something turn based. This gives plenty of time to manage inventory. The JRPG turn based combat system is somewhere I could imagine individually controlled inventories really shining.
     
    tedthebug likes this.
  9. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    I don't see why a multi-character inventory would require a game to be turned based. I understand that inventory management across multiple character at real time would require more time; if the time scale can be set to 0 you can swap inventories and ammo; without time as a concern

    I really disliked the war hammer inventory last i played it i was thinking i wish i could get rid of the useless equipment in a meaningful way such as sell or refine; i was never a fan of the Warcraft games but that mechanic of equipping items to hero's in an RTS was pretty unique. I'm thinking more on the lines of the things i have seen in games that i liked and want to implement;
    Examples
    boulders gate allows you to open corpse looting windows but it there are items on the ground you don't always see items unless you hover over them;
    the problem was if you open inventory window the items on the ground in proximity are not visible
    :) I am proud to say there is a ground window; but this requires additional GameObjects

    in sword of the new world characters have individual equip slots and a single inventory; i like individual equip; but not the individual invetory;

    project zomboid allows you to loot containers in an area; that is implemented relatively easy; (by doing an overlapping sphere cast from the activating characters point;) :) implimented !! i love this design to bad the games in 2D

    pillars of eternal has individual inventories; weight systems; ;) Coming soon !! i like the game too bad character customization is nonexistent;

    the original design question is How Do i implement an inventory system with unique items that have mods and durability and at the same time minimize the amount of game objects in a scene; the scripting i'll figure out with help from google the design ;) and this awesome community;

    instead of swapping GO from inventory to inventory; what i decide was to swap references to the item form the itemdatabase in the scene;
    the item database GO in the scene populates its values from the resources folder;
    I think that will be sufficient enough to reduce the amount of game objects in the scene for now;

    before i had it so every inventory had its contents as children with the renders off; consumables just had a count variable. this is not a good design;

    i want the inventory to be a little unforgiving, i was thinking also about a tile based inventory like in diablo; the number of tiles would reflect the backpack or bags equipped to the character.
    currently it is set to single tile same as most games when i create the Bag Class its on equip will adjust the characters max inventory.

    weight would be the limit imposed by the characters attributes; strength endurance ect....
     
  10. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Are you looking for input? Cause, several replies have warned that most players will find this design overly complex. That complexity will add difficulty, distractions, confuse goals, and muddy the feedback they are receiving. In other words, it will destroy all 4 requirements of flow.

    Te BEST feedback is to build a quick & dirty, working prototype. Then, give it to someone to play. Don't say a word, just give it to them and see what they do. "It's not ready yet", "I need to tell you how this works", and "it needs more features for it to make sense". Those are excuses.

    Gigi
     
    Master-Frog, tedthebug and Kiwasi like this.
  11. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You seem to be mixing game design and implementation. Forget about the amount of GameObjects in the scene. That's an implementation detail. Use this forum for feed back on exactly how the game should play. How many inventory slots should you have. Should inventory be shared or individual. Should the game pause during inventory management.

    Then move into implementation. The scripting forum is great for this. There are a ton of people there that will discuss code design. This is where you start talking about the number of GameObjects you need. You talk about optimisation and lists and references and collections.

    Mixing the two tasks is not a good idea. Scripting should be to your game design, it should not dictate your game design.
     
    buckius82 and tedthebug like this.
  12. buckius82

    buckius82

    Joined:
    Nov 19, 2013
    Posts:
    40
    For design I want Inventories to be small, making its spacce more valuable also gigi braught up a goodd point and I agree picking up multiple objects by clicking would be poor design. Thats why a ground window was added. I wiil finish wat I have and see if I can get quick demo up But I am considering adding tiles.
    Tiles that are determined by backpacks satchles , and racks.
    You braught up good point about warhammer an I think for equipable slots ill just have 5 2 weapons a backpack and and 2 item slots. It had a simple equipment system.
    Because i want something more survival I wont have tiered or colored items. No epic mauls of zombie slaying.