Inventory Amount - Infinite item

Temmy

New member
Hello

I want my player to have an infinite amount of an item.

My understanding so far is that you declare the amount of things the player has in the inventory script component. At this point I can't see a way of declaring something as infinite (I tried common things like -1 but that didn't do anything)

Capture.PNG

How would I setup an object with an infinite amount?
 
Last edited:
I don't know much about throwable objects, but is there a way for the grenade to not be 'consumed' when using it with the Use Ability?

Otherwise 999 or a higher number would have the same effect. And if you wanted to make it display as an 'infinite' symbol ( ∞ ), then you can copy and paste the unicode character, replacing the text value in the UI element with it. (and not update the persistent item counter).
 
Last edited:
I don't know much about throwable objects, but is there a way for the grenade to not be 'consumed' when using it with the Use Ability?

Otherwise 999 or a higher number would have the same effect. And if you wanted to make it display as an 'infinite' symbol ( ∞ ), then you can copy and paste the unicode character, replacing the text value in the UI element with it. (and not update the persistent item counter).

Sorry I'm still new to all of this so I don't know what the Use Ability is?

I've combed through the item's settings but couldn't spot anything to do with preventing it consuming.

Grenade.PNG
 
I don't know much about throwable objects, but is there a way for the grenade to not be 'consumed' when using it with the Use Ability?

Otherwise 999 or a higher number would have the same effect. And if you wanted to make it display as an 'infinite' symbol ( ∞ ), then you can copy and paste the unicode character, replacing the text value in the UI element with it. (and not update the persistent item counter).
Oh! Perhaps you meant the Item Use Ability on the player gameobject. Had a look there as well but couldn't spot anything that would reduce the amount.

1603133576256.png
 
Currently there's no direct method via a setting in the item or character's inventory to prevent an item's count reducing when it's used.

However, when the Use ability is used, it sends the "OnItemStartUse" event. (See Use.cs->AbilityStopped.) So, you could register to this event and increase the number of that item in the character's inventory by 1 whenever it's used. I think you should just create a subclass of the GrenadeItem component, which registers to the "OnItemStartUse" event and adds 1 more of the item when that gets called. ShootableWeapon.cs has an example of how to register to the OnItemStartUse event. (It registers the event to its ItemStartUse method.)
 
Turns out you can actually just not specify a thrown item definition on the grenade and it'll still work without consuming any item at all.
 
Turns out you can actually just not specify a thrown item definition on the grenade and it'll still work without consuming any item at all.
Sorry Andrew I don't follow. Could you post up a screenshot of the thing you're referring to?
 
Sorry, turns out you can't do that - not yet anyway..! (You can with shootable and melee weapons...) An "Infinite Use" option is being added to the ThrowableItem component in an update soon. For now, you can comment out line 476 in ThrowableItem.cs:

m_Inventory.AdjustItemIdentifierAmount(m_Item.ItemIdentifier, -1);

Sorry for the confusion!
 
Top