Download

Remove items from structure blueprint

Hi! I tried to follow a tutorial UMG UI and change it for suitable for my project. I spent long long time to make pick up item the way i want it. But for dropping the items things goes wrong. Please help?!!!
First, I have inventory variable in mycharacter blueprint instead.
Second, I want all items drop at once when mycharacter overlapping a trigger. So no need mouse cursor choosing and no options menu.
Third, I do the dropping items nodes in Level Blueprint.
Here is the nodes
529da3aadde452aa13d5377007dfc1cf53fa0e4a.png

How are you handling the picking up? If you are destroying the actor, you need to spawn a new one, if you are attaching it to another actor try detaching first.

Also, if you are trying to clear out an entire array, use the clear node. If you don’t want to do that, try the remove node and plug in the current item from the for each loop (just to be sure that what you aren’t removing an item you haven’t gotten to yet, and for clarity)

Sorry but your BP is a bit of a mess and I only glanced over it but a couple things:

  1. Understand that you aren’t removing anything from a struct. A struct is nothing but a template that defines how data is structured. What you are removing is elements in an array, and those elements are of that struct type.
  2. Removing indices from an array while iterating through that array is very bad practice. I’m not sure if BP somehow guards against the nasty, but generally this is a very bad thing to do and can at best cause all sorts of weird hard to trace errors and at worst crashes of an application.

If you are just trying to remove all the items from the array, as _cDub suggests, just do Clear on your array

yeah. Clear node do much better in my situation. Thank You!!!