How can i spawn an actor out of an array (inventory)
So hey there,
I need your help at this point cause im not so familiar with c++ or blueprints.
What ive done until now is creating a blueprint called BP_Item which represends items that can be picked up and droped down.
I manage the pick up by creating an array of that blueprint and adding it to it. Than i delete the actor out of the scene.
My problem comes up when i want to spawn this actor now because i can only find the spawn actor from class function. Since the array provides BP it cant be combined by it.
Also i want to create children of that item blueprint which also should be added to the array and be spawned out of it again.
I found a solution where i created an inventory blueprint which contained an actor variable with the blueprint as value. And spawnt it from this with using the inventory class. I got that from another user an i dont get that at all.
I just want to save the different bp_item_childs in an array and spawn them out of it. I hope you have a simple way to explain me what im doing wrong.
Since im posting from my smartphone i can provide pics of the blueprints tomorrow if you need them.
Thanks for your answers (:
asked Jul 18 '14 at 12:29 AM in Blueprint Scripting
Ask yourself first if there is anything you need to save with the actual blueprint instance which is picked up. Does it contain values that is unique and must be stored? If not, you only want to keep track of which items you have in the inventory. For example, why not store arrays of identifiers? (numbers, strings or class') For the player it will not look any different if you delete the item and then recreate it again when you want to spawn.
Just as an example, you could create a class array for your items:
When you pick up an item, you only store the ID of that item. So your inventory array could be:
Inventory: (int array)
(which is potion, potion, sword)
So when you want to spawn that item you use your inventory ID to get an index in the class array, then spawn that class. Open the image below in a new tab and you will see what I mean.
There is no need to store the actual object unless there is something unique about it. Using identifiers is a common way to simplify data flow, very common in databases to mention one example.
Follow this question
Once you sign in you will be able to subscribe for any updates here