Forum rules - please read before posting.

Remove last item added


Hey, I have a system where you click a hotspot and it automatically adds an item to your inventory. 
I'd also like to have a global button that can remove the last item you added.

I thought I could work it somehow with the new Inventory : Check Selected - Include last selected, but not exactly sure how.

Would it make sense to have the option "remove Add or Remove : Remove last selected" ?

Comments

  • I'm not sure that's something that would be used by many others.  What's the purpose for it, in the context of your game?  Know that it is possible to auto-select an item regardless of whether or not its in the player's inventory with the Inventory: Select Action.

    Provided that items are added in order, it can still be done through code by removing the last item in the List:

    AC.InvItem lastItem = AC.KickStarter.runtimeInventory.localItems [KickStarter.runtimeInventory.localItems.Count-1];
    AC.KickStarter.runtimeInventory.Remove (lastItem);


    You can place such code in a function within a new C# script, attach it to a GameObject in your scene (or make a prefab), and use the Object: Call event Action to invoke it at runtime.
  • Thanks for the answer Chris, it turns out there was a much more simpler way to get my desired effect using variables. Thanks again!
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.