Search Unity

In the world inventory system - Possible but is it harder than a regular inventory system?

Discussion in 'Scripting' started by Deadlyapples, Mar 8, 2018.

  1. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    So I am really enjoying learning C#, Unity and how they work together and it is really fun seeing things come together.

    Currently have a Player Controller which links to a Stat Manager which monitors things like Health, mana, energy, hunger, thirst and tiredness and these stats interact with the play controller. So if you are low on energy you can't run etc etc.

    But I want to work on a UI inventory system now and have watched several tutorial playlists from start to finishing and got a few things working. The issue is that because I am new I am finding it hard to remember most of it and following along is really hard.

    But I want to try a different approach which would be using a hotkey and in the world inventory system.


    So instead of a UI panel your inventory is your character.

    You have a backpack : Bit the B key to place your main hand weapon in its shieth and swing round the backpack, you can see into the backpack and select items etc.

    So instead of UI's it is all in the world.

    There are no items stored as data only items in the world.


    Just a thought and I wouldn't mind some advice.

    Really loving learning this stuff.



    So the idea:

    In-game Character Slot Locations
    • Head
    • Chest
    • Legs
    • Boots
    • Hands
    • Back
    • Left Side
    • Right Side
    • Codex
    • Pouch
    Interactions

    All interactions with the parts of the "slots" are done via hotkeys. Each slot has a hotkey and the context in which the slot is interacted with is based on what the characters hands are holding.

    Interaction Examples

    Scenario - Equip better boots

    Empty the characters hands by either dropping the items in the characters hands or placing them in a container or on an available "slot".

    Hold the Boots hotkey ("B") Which causes the character to begin to remove their currently equipped boots.

    Now the boots are in the characters hands. Drop the currently held boots which are the old boots.

    Pickup the boots that are on the ground so now the character is holding the new boots.

    Hold the hotkey ("B") and the character begins to equip the new boots.




    To me that type of system of inventory management seems really interesting and I really want to give it a go!
     
    Last edited: Mar 8, 2018
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    It's a cool idea. I've played with removing UI in a lot of designs myself.

    You will run into issues though, annoying issues that you don't normally think about with a UI system. A bunch of items in a pack could obscure one another. There's no easy way to balance the capacity of a backpack, or balance how much space (how many slots) each item consumes in a backpack.

    These may be the kind of thing you want for you game but there are definitely going to be things to consider, and far more than what I just mentioned that you wouldn't need to think about, or have known solutions with a UI system.
     
  3. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    Sure.

    In our current game we don't really have a robust inventory system (I haven't really upgraded it to be as such yet). But we needed multi-weapon support. So really we just have a 'WeaponSatchel' script, and Weapon prefabs. The weapon prefabs exist in the world, and the WeaponSatchel handles calling the appropriate animations to activate and deactivate which weapon is visible.
     
  4. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Yeah, depending on your game and how high detail and how many variations on items you want, this approach may not scale well. You'll have all those items, textures, models and animations in memory. the bonus of a UI inventory is all you need is a small icon and then load and instantiate those items on the fly, reducing memory and overhead impacts.

    But then again I don't know if this is an issue you might need to deal with. If you don't see it being an issue then do what's easiest to get the desired game design result.
     
  5. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    Awesome! Thanks for the responses! Wasn't expecting any! Haha xD

    Yeah I am new to it all really but it makes more sense to me in some ways and I am looking at making a simple visual style adventure game which revolves around inventory management with dungeon exploring. So you might want to grab loads of things but the player will have to choose what they want to take and what they take might effect how their next adventure into another dungeon might go!
     
  6. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    I guess the question is, does this type of inventory system add anything to the game in terms of gameplay for the player? It seems like a very complicated way to change a pair of boots... but if someone can come running past and steal those boots while they're on the ground and that's a fun thing to have happen then maybe it's a good idea. If all you're doing is adding steps to a task which will always be completed then maybe it could be simplified to 'click on new boost and they pop onto the player character and the old boots pop into the world where the new boots were.
     
  7. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    I guess that could be a good first step anyway because it would probably be easier making it swap instantly instead of having to wait and play an animation. But the concept of a physical inventory is more appealing to me than a list like Skyrim or an RPG inventory like World of Warcraft. Either way I am going to try it ! :D
     
    Antony-Blackett likes this.
  8. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    So I have a rough implementation of it done at the moment.

    Can see what objects can be picked up and then using the E or Q keys you can pick up the item in either Q = LeftHand E = RightHand.

    The objects when picked up dont interupt raycasting.
    You can then drop the objects and they return to normal like normal rigidbodies.


    This is expandable to include the head, chest, legs, gloves and feet!
     
    Last edited: Mar 8, 2018
  9. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    Update.

    So it turns out at least for me that placing objects in sockets and as children objects to the player is quite easy to use and understand but potentially not as performant because the objects are still being rendered not being converted into data. But you can do some cool things.

    Currently have a left and right hand. Both pick up and drop items. Can pick up helmet and place it on the players head.

    I want to work on an external socket if system linked to other objects.

    So you can look at a chest for example and see available slots and place the held item in the slot. Also want this to work for crafting and trading. Place materials in the slots, perform the action, craft the potion or the sword etc.