Forum rules - please read before posting.

I need help to identify odd inventory behavior source

Hi!

I'm facing a strange behavior when moving items from slot to slot in my inventory.
I uploaded two videos to show both the problem and the settings:

What I'm trying to accomplish here is to have an inventory made of two different inventory boxes, one for one category of items (with long icons) and one for other category of items (with square icons).

Everything works fine (when picking up items or navigating through the inventory), until I move items from one slot to another (as seen in one of the videos)

I know I can disable that function so the player wont move the items, but I need the player to be able to, and also I would like to understand the source of the problem.

Thank you!

Comments

  • The issue is that both Inventory elements are displaying the same Item Collection, but filtering out items they shouldn't show. Modifying one element is going to affect another.

    I will attempt a recreation. Can you share an image of your Settings Manager, as well as share your AC/Unity versions?

  • The issue is that both Inventory elements are displaying the same Item Collection, but filtering out items they shouldn't show. Modifying one element is going to affect another.

    Thank you Chris! Although I don't quite understand it yet, I'm glad you spotted the error.

    Image of the Settings Manager:
    https://imageupload.io/C6tpTj2rEqnZa2a

    My AC version is 1.78.4x
    Unity 2022.3.6f1 (Mac)

    If needed, I would gladly share you the project itself.

  • Thanks for the details. I've recreated the behaviour.

    It's a limitation of the Inventory system, I'm afraid. If you separate the same Inventory into separate boxes with categories, then you'll need to avoid empty spaces brought about by re-ordering.

    To explain a bit further: when you have an empty slot inside a collection of Items, both InventoryBoxes will display that same empty slot. Since an empty slot has no item, and therefore no category, it can't be filtered out.

    What you'll need to do is instead have each InventoryBox element display a separate collection of items. You can have the top element, which shows most of the categories, display items from the Player's Inventory, but the bottom will have to show a separate collection.

    This is most easily done by placing such items in a Container, that you can attach to your Player prefab (if the Player is spawned in via the Settings Manager).

    To this Container, attach a Remember Container component with Retain in prefab? checked so that its data is saved with the rest of the Player's data.

    You should then be able to run a Container: Open Action, with Open in set element? checked, to display its contents in the bottom InventoryBox, whose Inventory box type will need to be set to Container.

  • Great, I'll try it out and let you know when I get it right!

    I have two more questions about the inventory:

    • I've been trying to fix where the name of the items appears, modifying the rect transform property and such under the InventoryUI settings, but so far I'm not being able to. Could this be related to the same reason? (the inventory with two inventory boxes).

    • And also, after I select an item, if I close the inventory I can still see the item (probably for further interactions). I'm sure there's a way to disable that, but I still can't find it. (Of course I go through the manual first and the forum itself).

  • I've been trying to fix where the name of the items appears, modifying the rect transform property and such under the InventoryUI settings, but so far I'm not being able to.

    The item's name appears inside the Hotspot label, which will be in the Hotspot menu if you're using the default interface. This is a separate Menu to the Inventory, and is the same label that appears when over Hotspots when the Inventory menu is closed.

    You can control the Hotspot menu's position within its own properties - setting it to Manual will prevent it from moving with the cursor.

    And also, after I select an item, if I close the inventory I can still see the item

    You can manually de-select the item with the Inventory: Select Action's "Deselect Active" option. Run this in the Menu's ActionList when turn off asset to have it kick in when the menu closes.

  • The item's name appears inside the Hotspot label, which will be in the Hotspot menu if you're using the default interface. This is a separate Menu to the Inventory, and is the same label that appears when over Hotspots when the Inventory menu is closed.

    I'm not sure what you meant by "default interface" but I was using UnityUI under "Hotspot Properties" > "Source". I didn't manage to correct the position as desired, but I switched to AdventureCreator and I think it works just fine for what I need.

    You can manually de-select the item with the Inventory: Select Action's "Deselect Active" option. Run this in the Menu's ActionList when turn off asset to have it kick in when the menu closes.

    This one was so obvious, I'm clearly not functioning at my best 😅

    Thank you Chris, I didn't get to test the previous advice about Containers but as soon as I do, I'll let you know.

  • I'm not sure what you meant by "default interface"

    To clarify: I was just referring to the default set of Menus, i.e. Hotspot, Pause, Save, Load etc, that you start with after using the New Game Wizard.

    It sounds like you're working with the same Hotspot menu I was referring to, though.

    With Unity UI, it's a little more involved: after setting the Position to Manual (which prevents AC from automatically re-positioning it), you'll then need to edit the UI prefab itself. With the default HotspotUI prefab, this is just a case of moving the "Panel" RectTransform to where you'd like it to appear.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.