Forum rules - please read before posting.

Making an inventory item usable an exact number of times

As the title suggests, I'm looking for the best way to make an inventory item usable exactly 3 times. For more context, I'd like to make an item that can be used in combination with another item an exact number of times. Let's say that I have a Shotgun and I picked up an ammo box that contains 6 shells. I'd like to be able to drag this item 3 times (or however more) onto the Shotgun and have a 3rd item (crosshair) spawn. This is related to my previous "making a shotgun" thread. I've set everything up, but whenever I try to use that item only 3 times it seems to spawn indefinitely when clicked, even though I have it set up to only be used 3 times. Do I need to use some variable or am I missing something in the settings? A link to a tutorial or a similar topic would be appreciated if this topic has already been covered.
As always, thanks a bunch!

Comments

  • In your example, could you elaborate on the relationship between the number of shells and the number of times you can combine them with the Shotgun? I'm not clear on the exact usage here.

    You can typically either rely on a Variable to keep track of things (which is easy to set up, but independent of the item), or an Inventory property (which is more difficult, but is directly linked).

    You mention you've already set something up - can you share screenshots?

  • edited November 2022

    Video of mechanic here <- this is the mechanic working in the game with some crappy place holders. My interest is in the "Shell" inventory item (red ones), When I click the Ammo container I'd like to either spawn 3 "shell" items or drag the Ammo container directly onto the Shotgun. I'd prefer the first method, but it doesn't matter as long as I can control the amount. This Ammo Container will be a prefab and I'd like to control the pick up amount each time (it's going to be different).

  • Inside the Ammo container Item's "Use" Interaction, you can attach the Inventory: Add or remove Action to spawn 3 shell items in your Inventory. Check Set amount and then Increase count by to 3.

    To make sure that each of the shells have their own space in the Inventory, check Can carry multiple? in its properties panel, and then set its Slot capacity to 1.

    For Ammo containers of different sizes, you can override the "3" with an Integer ActionList parameter. To control the parameter, you could then either create separate container items that each run this ActionList with a different value, or use scripting to sync it to an Integer property value associated with the item.

  • thank you @ChrisIceBox I finished it and it works really well.

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.