Search Unity

New/Old Inventory System

Discussion in 'Works In Progress - Archive' started by Tiki, Jun 17, 2014.

  1. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello guys, things have been insane, the story game is basically complete and only needs us to add content to play. Please come check out the twitch feed after 8pm EST, and I will be adding a video that demos it as well. Meanwhile, I am looking into setting up an error reporter for my current plugin CityScaper, that I will indeed pull over into this plugin as well. All the information is still safely stored away, and it is next on my list as soon as I fix up my current release. I am more or less done with the grit of my story game, so I am full-throttle on getting back to this plugin again. My hope is to be working on it in a few days to start familiarizing myself with the code again.

    I apologize for the wait, and the inconvienence, but I was focusing on too much at once, and felt a need to narrow my project scope.

    twitch.tv/tikihubtony
     
  2. Hrothvitnir

    Hrothvitnir

    Joined:
    Apr 26, 2013
    Posts:
    109
    Do you have access to the Unity 5 beta? If so you may want to target that at this point (or that plus unity 4.6 for legacy projects).
     
  3. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    I plan on it, I want to make sure I properly wrap up the story project and CityScaper first so I have stable projects to integrate new features into after I'm done with this tool.

    http://www.twitch.tv/tikihubtony/b/630360890

    I've temporarily archived a short video explaining the story project if anyone is wondering why the long delay.
     
  4. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    I've been streaming work at my twitch - twitch.tv/tikihubtony - if you want to see how the inventory tool is going personally.

    I've rebuilt it from scratch using my knowledge and have the tool completely finished, with the UI currently displaying picked up items pivoting on the cursor and allowing you to place them back down at a the cursor position. It uses prefabs and the UI 4.6 gui features built in unity 5... I have to finish setting up the display for containers and master list(I have the day off tomorrow, will easily complete that). Then I have to set up the logic for placing and storing.

    Wanted to keep you updated, but I wanted to master the 4.6 UI controls before I got back to you also. I apologize it's coming so late.

    http://tikitemp.netii.net/Players.html

    Press E to pick up and put down objects. R to rotate. Cylinders are two different items I set up, the block is a container. I'll continue to update that webplayer each night.

    Update: Uploaded updated webplayer. You can now display the master list of containers ( Press I for inventory), and click on the desired container. Next is making the list update as you add containers -> Removing containers and closing windows -> Storage Logic

    Update: Uploaded updated webplayer 3/13/2015 2:00 AM EST.
    Can now close and open containers at will. Starting on storage logic

    Update: Uploaded updated webplayer 3/13/2015 9:00 AM EST.
    Windows now focus to the front when selected. Storage Logic is final step.

    Update: 3/13/2015 11:25 PM EST
    Lots of hours at the day job, progress slightly slower until Sunday morning. Managed to set up the base for the slot recognition when placing items in containers (recognizes you're clicking on a container with an item in hand without command overlaps).

    Update: 3/16/2015 9:42 PM EST
    Back on track tonight and tomorrow. With tomorrow off, I should have most, possibly all of the coding finished, and will pump out a few custom models and textures to pretty it up.
     
    Last edited: Mar 17, 2015
  5. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello!

    A quick update!

    http://tikitemp.netii.net/Players.html
    E to pick up and put down objects. R to rotate. I to open inventory master list.

    3/16/2015 11:10 PM
    The UI now recognizes fitting items and snaps them into location, rotation included. Runs three simple phases:
    1. Check that mouse pointer remains over a slot
    2. Check that all item slot centers fit within a slot in that container
    3. Snap and leave open for further input (store in container)

    Tomorrow (I actually have a day off), I'll be working on the logic to store them, and that's the last of the skeleton code. If you wish to save your character's inventory, you'll need only save and and instantiate the player's gameobject on exit and load.

    If there are any suggestions or questions, now is a great time to see them incorporated quickly!
     
  6. Hrothvitnir

    Hrothvitnir

    Joined:
    Apr 26, 2013
    Posts:
    109
    Did you update the webplayer? Doesn't seem to do anything different for me but that may be due to my other problem:
    I would suggest locking and hiding the mouse cursor and maybe using a raycast for the world object interactions (ie pick up something). Can be a bit frustrating otherwise, especially if - like me - you're on a multi-monitor setup.
    When doing inventory stuff, I would re-enable the mouse cursor, but
    A) lock it to the viewable area, and maybe center the cursor or something, so it isn't off-screen.
    B) disable mouse look, so you aren't spinning in circles while trying to move inventory stuff around.
    Just basic usability stuff, but it will help sell your product I think.

    ---

    Also, how is it supposed to work? The blue circles with an arrow are occupied slots? There are don't seem to be enough open slots any of the objects to fit (though I guess this functionality might not be in yet). To deposit an item into a container, do we click or press "F"? I guess the last is one I would figure out playing the demo if its implemented, but I didn't notice anything yet.
     
    Last edited: Mar 17, 2015
  7. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Ah, sorry, there are two types of containers, that's my fault for not explaining. You can make as many types as you'd like, I have two I made with the tool put in there. One is small (named satchel) and the other is large (a 10x10 named backpack). The large one will fit the objects for the "snapping" while the smaller one is too small as you noted. I'll add a smaller item that fits into both containers so that it is a more intuitive example. I'll also add some mouse centering as you suggested, I'd been avoiding that as I figured the developer would have their own methods for centering and locking the mouse.

    I apologize for the lack of representative graphics and models to make more sense of what you're seeing, I will add some before it is released, but I want to focus on functionality first. The ground textures represent background textures like the top-down of your opened backpack or the side view of holding a sword or axe. It is optional to display slots on items, but not containers. Cylinders are items, cubes are containers, and hitting I (If you've picked up at least one container) will open a master list of your current containers. You can choose a unique image to represent the container's slot in the master list.

    You can't deposit an item into the container yet, but my thinking was that you'd just click, that buttons were for interacting with in-world objects, and once you bring up the inventory, it's just a mouse process (and R to rotate). I'm actually just starting work on the storage logic now. Right now it displays containers and items that are picked up, and snaps into place any item that fits into empty slots. So if you have the sword (the cross type item) and fit the mouse's centered slot on an empty slot, and the rest of the slots in the sword line up with slots on the container, it will snap the item into place to show you it fits there.

    I know with the MacGyver aesthetics it's a little confusing still, just let me know if you have more questions, those are great suggestions, especially for the WebPlayer demo!


    Updated Instructions:
    Press E to pick up and put down objects. R to rotate. If you've picked up at least one container, I (i) for inventory list, and click on a slot to open that container you've picked up. Cylinders are two different items I set up, the blocks are containers, there are two, the double up arrow in the master list will fit items, the other is too small.

    Update: 3/18/2015 12:57 AM EST
    Updated Web Player. You can now store items. You cannot remove them yet (my next goal). I have not had enough time to properly test, but I am not finding any errors yet. Also locked cursor to center to be unlocked while managing inventory. Slots of deposited items will not allow overlap, however the background images for items may overlap, as they extend beyond active slots.

    You may have to force refresh the page to get the updated version, I found I was playing the last (cached) version when loading the page. That or your cache will be updated over time anyway.
    http://tikitemp.netii.net/Players.html

    Update: 3/20/2015 9:54 AM EST
    No update to the Web Player, yet. I've got the item removal system working with one small error. Now that I've found the error, I can find a solution for it and things will progress quickly again. Once this is ironed out, the last of the Game UI coding is to let you pull containers out as long as they are emptied. There are some features I'd like to add after release, like even more customization to the master list, but if you have any suggestions or notes, the next few days are a great time to make them. - Hopefully I'll have the next Web Player update by the end of the night, with item adding and removal, but no container removal.
     
    Last edited: Mar 20, 2015
  8. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello!

    Update for 3/26/2015 12:21 AM!

    The program is almost complete. The last coding I have to finish is removing the containers, which might mean a slight rework of the way they're collected. I'll take a little bit of time on this to make sure it's intuitive and clean. I have Updated the Web Player. You can now do everything BUT remove containers. This means picking up, storing items, removing them, and all combinations of opening/closing containers with/without items is working smoothly ( I cannot find any errors, please report any ). Go ahead and give it a try :).

    http://tikitemp.netii.net/Players.html

    The last few days I've been tackling a bug pertaining to a 3-piece Jagged Array I set up, so I apologize for the slow progress over this week. Coupled with a floorset and thousands of units of shipment at my retail job, I've been pretty busy :/. Now that I've figured that bug out, I don't expect any more complicated problems while completing the last code piece.

    Update: 3/26/2016 12:59 AM
    Updated Web Player. Disabled Mouse Look when managing inventory. Will highlight code segment and suggest Devs use their own mouse look system, as this is just a slightly modified version of the FirstPersonController.
     
    Last edited: Mar 26, 2015
  9. Hrothvitnir

    Hrothvitnir

    Joined:
    Apr 26, 2013
    Posts:
    109
    Looks good so far.
    I will have to look at the code I guess, but probably I won't be using the multiple bags functionality. Can we set it up so there is only one bag, and when you pick something up or press "i" only that bag is seen (open automatically), and you don't have to click on an icon in the inventory manager box to open the bag?
    I guess another way to look at it would be, if there is only going to be one "bag" per character/player, we don't need an inventory manager window, just the bag window itself. For a fast paced game like a multiplayer fps, messing around with multiple nested windows would be a problem.
    Maybe something to think about for a future feature, but if not I can probably figure this on my own at some point.
     
  10. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    That's much easier to set up, won't take more than a day Hrothvitnir :). Given the current structure, I will incorporate a "no master list"/"one bag" option before release. It's set up so I can also make the number of bags infinite if I wanted to, but for now it's set to 9, and I will release it with that cap customizable as well.

    Update!!: 3/26/2015 11:32 PM EST
    Updated Web Player. You can now remove containers, and the container pickup system has been overhauled. You now hit E to pick them up, drag them to your inventory list, and click to add them. To remove them, if the container is empty, press E to pick them up from the list. The inventory list now opens at any time, with or without already picked up containers. All other controls remain the same:

    http://tikitemp.netii.net/Players.html

    Press E to pick up and put down objects physically. Click to move items through inventory management. R to rotate. I (i) for inventory list. Cylinders are three different items I set up, a sword, an axe, and an apple. The blocks are containers, there are two, the double up arrow is a large "backpack", the other is a small "satchel".

    Note: All that is left for me to complete is a "no master list" option, a simple inspector interface for scene variables, and some pretty custom models and artwork to package and represent the concept in a more effective way. The asset is essentially done at this point, and will be hitting the marketplace soon :)!
     
    Last edited: Mar 27, 2015
  11. Hrothvitnir

    Hrothvitnir

    Joined:
    Apr 26, 2013
    Posts:
    109
    Another "bug report" for you:
    When you click on the bar at the top of an inventory box or the inventory manager, it tries to recenter the box on the mouse click I think. When I was not full screen this wasn't a big deal, probably working as intended. But in full screen mode (possibly because I'm on a 3600x1920 setup, or 3 monitors or something like that) this became a major problem. Rather than re-centering on the click point, every time I clicked the box would move a significant distance to the right and upward. Depending on where it started, after a few errant clicks it would be off screen. I could click-drag it back into position if I catch myself, but once off screen there isn't any way to get a box back. Not sure about your plans, but if it were me I would look at removing the "recenter on click" functionality, doesn't really add anything as far as I can see since people can move boxes around by dragging anyway.
     
  12. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    The code is set up to center the handle on the mouse as long as you click on the handle, and stays centered until you let go of the mouse button. I plan on modifying it slightly yet, so that it captures the point your mouse is on relative to the handle, instead of repositioning - but I'm not sure how this error is occurring for you. I'll have to do some experimenting to find the problem. If you have any more information that could help, please let me know. I haven't tried fullscreen with it yet, so I'll try that and see if I can reproduce the error.

    Update: Apologies! It appears I uploaded the wrong file yesterday! :( The new version is now properly updated, try it now!

    Update 2: I see the error you're talking about Hrothvitnir. Thanks for the report, I'll get right on it. It has to do with fullscreen's modification of the mouse position input function it seems.

    Update 3: Error Fixed.
    Now resets the 4.6 UI Canvas size when entering and exiting fullscreen.

    http://tikitemp.netii.net/Players.html

    Press E to pick up and put down objects physically. Click to move items through inventory management. R to rotate. I (i) for inventory list. Cylinders are three different items I set up, a sword, an axe, and an apple. The blocks are containers, there are two, the double up arrow is a large "backpack", the other is a small "satchel".


    Update 4: Save system set up. Just save the "Inventory" GameObject, and reload it when ready. Inspector cleaned up.
     
    Last edited: Mar 28, 2015
  13. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Hello!

    I'm going to spend some time working on the models and aesthetics tonight:

    Updated Web Player.
    Added New Web Player.


    http://tikitemp.netii.net/Players.html

    http://tikitemp.netii.net/Players2.html

    The second Web Player examples Hrothvitnir's idea for an FPS oriented inventory system. To switch between these two examples, all you do is click the "Skip Master List" checkbox, and set Max Containers to 1 in Unity's scene inspector, and this is the result.

    In the "FPS Oriented" version, press E while holding the container (moving it via the handle) to drop it at that location. It must be empty first.

    If you prefer it to not be droppable, and to start with the object. I can send a personalized file, or you can comment out the KeyCode.E segment where it drops. The save system is set up already, just add the container to the scene objects as detailed in the instructions we'll include, and the character will start with the container you want, not be able to drop it, and limited to a single container. That should suit your needs :).
     
    Last edited: Mar 28, 2015
  14. Hrothvitnir

    Hrothvitnir

    Joined:
    Apr 26, 2013
    Posts:
    109
    Tried the FPS version, looking really good so far. I can comment out the dropping. One thing I would suggest you do though, when the player picks up an item, test if inventory window is already open, and if not, open the inventory window automatically.

    Another thing I thought of that you might need is "persistent bags" - IE lootable containers that don't themselves get picked up by the player, like loot chests in rpgs, or enemy corpses (obviously the cubes in the demos are just placeholders, but as is they disappear on interaction because they get "picked up").

    The last thing then would be the dedicated equipment slots (could maybe be bags) that test if an object is the right "type" (ie is this a weapon or not) and send a message or call a function (to equip something or change the player model).
     
  15. Tiki

    Tiki

    Joined:
    Mar 3, 2013
    Posts:
    299
    Okay, so making a quick tally:

    1. A checkbox to automatically open windows on pick up.
    2. Lootable/static containers
    3. Weapon/Container types

    The first one is easy, I'll integrate that right away. The second is around a day long project, I think we had come up with that idea several months ago earlier in the thread actually. Not hard, just involved.

    The third is like adding a whole new piece to the program, might take a couple days. I'll probably release the rest first, and work on this while it's being reviewed, so it'd be like Patch 1.

    I'm thinking of adding a place to add names to a couple lists like "Back", "Right Hand", "Left Foot" for equipment slots, or "Weapon", "Provisions", "Tools", "Armor", "Clothing" for equipment types etc. Then let you assign equipment types to the equipment slots, add a background image, and something like the button system shown previously in the thread. When you click on each button - it switches between the equipment slot name and blank. The developer would be responsible for equipping the item visually to the player model, as the player model would be separate from the inventory system. You'd collect certain scripts on the Inventory GameObject you create and name, then check for the one that has your desired equipment slot name. Otherwise, the UI would allow placing items into this equipping screen, and set up that object. Using the name variable on that same script, you can load it's prefab. I will make sure to include the exact code to accomplish this in the instructions, it's only two lines. From there the developer would need to determine their own method of attaching said prefab instance to the player model.

    Maybe in the further future I can set up a 3d model screen where you insert player models, it'll render a preview, and you move slot boxes around the model and attach the same equipment slot names to them. Then it renders a 3d character equipment screen and automatically adds the objects to the player visually as well, both in preview and in game. That's a little out of my time range right now though, and might evolve into it's own tool altogether.

    Let me know if you have any thoughts, anyone?
     
  16. HR0THVITNIR

    HR0THVITNIR

    Joined:
    Nov 21, 2013
    Posts:
    24
    Sounds good.