playMaker

Author Topic: Simple Inventory System...  (Read 6165 times)

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 27
  • 3D-artist and fledgling Unity Dev.
    • View Profile
    • holyfingers.co.uk
Simple Inventory System...
« on: August 27, 2013, 09:53:09 AM »
Following on from my last post (http://hutonggames.com/playmakerforum/index.php?topic=4596.0) I've written up a few notes on setting up a simple inventory system:

http://www.holyfingers.co.uk/main/blog/2013/08/27/whats-in-the-box/

Here's a quick video of it in action:


As before I'd love to hear any thoughts or suggestions!

Cheers,

Nick
Twitter: @holyfingers

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #1 on: August 27, 2013, 03:06:43 PM »
This is awesome! thanks heaps :D I was actually planning on building an inventory system and writing a tutorial or releasing it. I'll just have to go with plan B - Dialog system :D
« Last Edit: August 27, 2013, 06:29:22 PM by LampRabbit »

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #2 on: August 28, 2013, 01:07:14 AM »
Just taking a look at it now, I take it that your game has a limited amount of items to pick up? My use will require an inventory item limit (INVENTORY FULL!!!), and the slot positioning aspect seems like an area to improve its use, once I've built your example ill add the limit and have a go at a better slot solution (haven't thought of one yet).
But so far so good, very easy to follow tutorial
« Last Edit: August 28, 2013, 01:10:06 AM by LampRabbit »

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 27
  • 3D-artist and fledgling Unity Dev.
    • View Profile
    • holyfingers.co.uk
Re: Simple Inventory System...
« Reply #3 on: August 28, 2013, 03:04:37 AM »
Hi there LampRabbit,

Yeah, the game I'm working on is a point-and-click adventure so there will only ever be one of each item and they'll all be listed before hand. You could limit the number of slots pretty easily by comparing an Array List Count with a predefined limit perhaps?

In terms of layout my approach is definitely very basic, I'm just having a horizontal line of items to scrub through. You could maybe have a separate array of Vector3 values to call on? Or even just add a few extra steps to the incrementation method I used, like, after every 4 slots reset the X and adjust the Y down to give you a new row?

Glad you found some of it useful though!

Cheers,

Nick
Twitter: @holyfingers

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #4 on: August 28, 2013, 03:29:26 AM »
Having an issue with the Array List Easy Load action ... do I have to create the autosave.txt file? (the tooltip says it is created :S) But I'm getting an error that the file doesn't exist.

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 27
  • 3D-artist and fledgling Unity Dev.
    • View Profile
    • holyfingers.co.uk
Re: Simple Inventory System...
« Reply #5 on: August 28, 2013, 03:52:58 AM »
Ahh yes, sorry you'll need to have a save file already existing to load at the start.

If you change the Start State to Idle here you can use the Save event to create a blank one, just temporarily set the name to autosave.sav:

http://www.holyfingers.co.uk/main/wp-content/gallery/inventory-tutorial-inventory-screen/inventory_screen_4.png

I was using the save/load events just to reset, so I had two different files, save.sav remains empty and autosave.sav gets updated every time I change scene. That make sense?

I should add a note about that somewhere, and possibly include a screenshot of the FSM for the Scene Select...
 
Twitter: @holyfingers

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #6 on: August 28, 2013, 04:23:25 AM »
Figured that was the case after hunting around the internet but now I'm getting another error, did you have to create a Easy Save Default Settings gameObject and if so did you see the default path? - the save array is giving me StackOverflowException
MoodkieFilenameData.GetPersistentPath ()
MoodkieFilenameData..ctor (System.String path, .ES2Settings settings)

Back to the internet hunt :P
Thanks for all the help

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #7 on: August 28, 2013, 04:25:36 AM »
Hahaha didn't take long to find -

"We've looked into this issue and we'll be submitting an update to address this on Monday, which will hopefully be approved by Unity by the end of the week."

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 27
  • 3D-artist and fledgling Unity Dev.
    • View Profile
    • holyfingers.co.uk
Re: Simple Inventory System...
« Reply #8 on: August 28, 2013, 04:40:17 AM »
Ahh, is the issue there related to encryption? Did you try creating a Default Settings object and making sure encryption was turned off maybe?

The default path on Windows 7 seems to be:

C:\Users\<name>\AppData\LocalLow\<company name>\<product name>

No worries, just updating the tutorial now...
Twitter: @holyfingers

escpodgames

  • Hero Member
  • *****
  • Posts: 666
    • View Profile
    • Assets
Re: Simple Inventory System...
« Reply #9 on: August 28, 2013, 05:07:51 AM »
Yep, while trying to fix the other error I tried everything ... including creating a Default Settings object and making encryption true :P

I've got it working at a very basic level (colored cubes) adding scene items to inventory works, just noticing a few glitches that I cant figure out- selecting an item and then selecting another can SOMETIMES result in varied results (would expect the selected item to scale up but sometimes doesn't)

EDIT - found the bug, all works except using inventory items with others (I just haven't set it up yet)
« Last Edit: August 28, 2013, 05:15:16 AM by LampRabbit »

gamedivision

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Re: Simple Inventory System...
« Reply #10 on: October 06, 2013, 03:40:32 AM »
excellent stuff thank you I was looking for something to get me going on this  ;D