I have an Backpack (Actor) with an simple array. I can put things(other Actors) in the Inventory (Actor Array). Everytime i spawn the Backpack Actor, all Actors from the Actor Array spawn around the Backpack Actor. If i grab the backpack again, every Actor get destroyed and respawn after i drop the backpack again (Spawned Item Array). This all works fine.
An example:
1,2,3 are different objects and 4 is my Backpack. Backpack
My problem is: I want to delete the objects from the inventory array, after i used them (for example: combine each other to get a new object).
I tried to take the spawned Actor Reference to âremoveâ from the array but it doesnât work. Same for âDisplay Nameâ comparison, because the names changes.
Iâm a bit lost right now because i donât know how i get a reference from the used actor to the original inventory array.
As far as my experience goes, if you want to destroy an item, first you have to remove it from the arrays it is present, or else it becomes a âpending for deleteâ.
If thatâs not the problem and you donât know how to delete a certain type of actor, you might want to give a tag to the actors, such as âWoodâ and âWaterâ. Then you can search for âHas Tagâ in a foreachloop.
Or you can have your inventory as a struct that contains a list of integer arrays, named after the items that they can contain. So you can lower or increase the number of the said integer array depending on what you use and pick up.