Forum rules - please read before posting.

Drop the first (or last inventory element)

Hi, I need the player drop the first (or last) inventory element when reach a trigger.
(when he pass though a zone in the game (a trigger) the first (or last) item falls to the ground, so I need:

a) remove first (or last) element from inventory
b) instantiate prefab in the scene based on the item left in the ground

eventually move the rest of items one step to fill the first (or last) slot in inventory, to get room to take another object. (something like an FIFO queue, I have 4 items and the first outs, the rest moves 1 step in inventory and the new element enters to the end of the list)

I don't see a way to do this with AC.

Maybe in combination with Playmaker?

Thanks

Comments

  • There's no way to remove the first or last Inventory item with Actions, but it's possible with some custom scripting.  The items are stored in the list:

    AC.KickStarter.runtimeInventory.localItems

    If you use it to find the first item (e.g. localItems [0]), then you can pass that to the function runtimeInventory.Remove (InvItem _theItem).  You can also read this item's ID or label, to work out what prefab to instantiate.
  • Many Thanks Chris! very useful info! :)

    When you say it cannot be done with Actions, do you mean that there's no Action in AC that make that, but that I should script  a Custom Action. right?

    Thanks
  • I reach this tutorials that seems what I'm looking for. Very good stuff :)

  • Hi Chris, I'm doing the following but is not working. I'm trying something simple: store first item in invItem var, debug the item (it shows the label and id 0 in console) and then call the Remove function without success.

     Could you point me in the right direction?

    override public float Run ()
    		{
    InvItem invItem = KickStarter.runtimeInventory.localItems[0];
    Debug.Log ("invItem: " + invItem.label + ", " + invItem.id);
    KickStarter.runtimeInventory.Remove (invItem);
    return 0f;
    }
  • I find the problem, I needed a refresh of the menu:

    PlayerMenus.ResetInventoryBoxes ();
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.