[BUG]

Paramedic

Member
Hello, I have 3 problems:
1). I use Item View slot container Item Action Handler, and I use E key to equip or unequip items. When I unequip Equipped item, there is still this item description left on description panel, like on the screen below. When i move to another slot and come back, then description is cleared. I want to clear description in the moment when I unequip item.
1672093281024.png

2) Second problem is with using drop item action on equipped items. When I drop equipped item, and pick it up and equip it again, I can equip this droped item by using equip item action on every empty slot that is in Inventory. I showed already videos on discord, I can't paste it here. One solution is disable drop item action on Equipment slots, but I would prefer to have this possibility. Maybe status of this slot is not changing when I drop equipped item? When I move to this specific empty slot and I press Equip item action, then I move to bugged item, it fix situation and it works well again.

3) It is not clear for me how to clean up scene from dropped items. I use my scene system, I have splash screen, main menu, gameplay scene, and all I have is on different scene, and I have transitions to each other. When I am on gameplay scene and I drop item, and then I come back to main menu scene, and again come back to gameplay scene, this items are still there, but actually they are just falling down on 2d scene, like they losted collision boxes or something, but this is not actually important, I just want to clean them up every time when I change scene.
 
1) The action should normally cause the grid to redraw... I wonder if it's not the case because you aren't using the ItemAction panel and instead calling the item action directly on input... but that doesn't really makes sense because if the Inventory was not redrawn the item would still appear in the grid.
So I'm not sure what could be the issue

2) That one eally bugs me, I have no idea how that's happening.

3) I have an idea for why this is happening. Drop items are pooled. Pooled objects that are returned to the pool will be parented to the "Game" gameobject which I'm assuming is in the "Dont Destroy On Load" scene within your project. So when you switch scenes the pooled items are not removed causing your problem.

When I had a similar issue in my game I would cleanup my pool everytime I switched scenes. But I did so manually. I would need to discuss with @Justin to see if we could come up with a generic solution because I know some other users had the same issue.



For the first two issues I wasn't able to replicate them in my project. So I would recommend you send us your project at support@opsive.com and we'll have a look at it in more detail.

PS: you can share videos in the forum using https://streamable.com/
 
Last edited:
Thank you for your email.
Thanks to the detailed instruction and well organized project I was able to reproduce the issues very easily.


1)
The Description does not have a direct link to the item action handler so it doesn't know that it should be redrawn when an action is pressed.

But the action does tell the itemViewSlotContainer to redraw when finished and the description has a connection to that. So I added an event listener to the draw event such that the description redraws when the itemViewSlotContainer is drawn.

2)
So the reason the item was being unequipped while pressing an empty slot was because both the InventoryGrid and the Equipment grid thought they had a selected slot at the same time.
So pressing "E" was first trying to equip empty and failed, but at the same time it was trying to unequip the equipped item on the selected slot.

I solved this by ensuring the equipment slot gets unselected when the panel is closed.

It required some additional tweaking because the display panel for the Inventory Grid and Equipment was not being closed, only the main menu was. So I added some code to ensure sub panels are closed when the main menu is closed



In the end it required changes in multiple scripts so I exported the relevant scripts in a unity package that I am attaching below. It uses your project structure so you should only need to import it and theoretically it will solve all your issues

All those improvements will be available in the next UIS update.


PS: Your game is looking very promissing :) I wish you all the best on this project
 

Attachments

  • Metroidvania-Unity_Script_Fixes.zip
    8.1 KB · Views: 4
Top