Hi
I have this code on a custom script which runs when a player picks up an item;
if (debugIsAwesome) { OllyTools.logWarning("Item added " + inventoryItemName); }
KickStarter.runtimeInventory.Add(KickStarter.inventoryManager.GetItem(inventoryItemName).id,1);
However, no matter how many items the player picks up (and how many times the script runs, there's only ever 1 instance of that item in the player inventory. The inventory item is set to allow multiples.
I can't share Imgur images as imgur is now blocked in the UK, but here's a link to an image that shows the above debug line being printed three times, the breakpoint also hits the inventory line three times, but the player inventory only shows one item.
https://drive.google.com/file/d/1BG9JOX7k49bGvUNguOmzmZo_nmZnIwZX/view?usp=sharing
Is there a correct way to do this? Do I need to see whether the item is already in the inventory, then +1 to the current count? Seems long winded.
Olly
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
What are your AC/Unity versions, and can you share the Item's properties?
Here's the items properties
https://drive.google.com/file/d/1MwXk1x2l9jrEP-kz1SLcqIIJLWcFUmwu/view?usp=sharing
AC 1.82.5 Unity 6000.0.34f1
Actually, I think it may be my understanding of the function rather than a bug or valid query.
If I use the following, it appears to work as expected.
KickStarter.player.Inventory.Add(new InvInstance(KickStarter.inventoryManager.GetItem(inventoryItemName)));