Hi everyone.
I am currently trying to build a simple system where I can randomly spawn chests in the world, that would also contain randomized items.
So far, I have been able to build my code that randomizes spawning for my chests in the level blueprint, but I am unable to figure out how to spawn an item in each chest.
The main thing I tried was to drag my first item actor blueprint into the chest actor blueprint, which created a child blueprint of my item in the chest viewport; but the issue with that is that whenever I interact with one chest, whatever I do with the item affects all similar spawned items.
Is there a way to spawn an independant item (that is also a blueprint) in each chest? Thank you.
1 Like
Regardless of whether the object in the chest is a static mesh or another blueprint, you can create both in the construction script, and set them randomly.
A static mesh can be spawned or you can use a mesh component.
A blueprint can be spawned in the chest, or you can use a child actor ( which is what was happening for you ). A child actor can also be set during construction. All it actually does is just spawn the blueprint for you at runtime 
Writing version of the chest code and then just placing copies of that around the level, is much easier than trying to control everything from the level BP.
If you want to make sure there a no repeating items, you can use a ‘chest manager’ blueprint that will hand out the next random item ( and remove it from the list ). Each chest ‘asks’ what to store on begin play.
I guess my issue is tied to the spawning of the item itself then.
There must be something wrong with my code as items either don’t spawn properly, or when I duplicate my chest, the items are all affected by the interaction done on one chest.
This is the blueprint I have.
Level blueprint (to randomly spawn chests)
Chest Blueprint. This is where I have a child of my item that is being called, as well as an animation to open the chest.
ItemBlueprint. This is where I have my custom event to spawn the item (and probably where I am missing something)
Any help would be appreciated! 
1 Like
All the code ( for now ) is in the chest
I needed the scale array because some of the items were too small or large, so I can scale them to fit ( you can set all of them to 1 to start with ). Also the ObjectScene is just a scene component that shows where I want the mesh to appear in the chest

1 Like
Thank you very much, I’ll test things around with your example! 
On the first screenshot:
Would you take a similar approach to spawn the item if it was an actor blueprint that has specific code?
For context, the item I want to spawn and pick is a blueprint stored in my inventory and available in my quick-use wheel.
1 Like
I’m a little confused. If the item is already in your inventory, why would you want to get it from a chest?
Do you want me to change it for so you can put blueprint actors in the chest?
Sorry for the confusion, yes I basically need to spawn a blueprint actor in my chest. 
What I was trying to say is that my item already exists in my project as an actor blueprint with some code, so I want to make sure that whatever I pick from the chest is not a simple mesh, but my actual actor that gets added to my inventory upon pickup.
1 Like
So, the chest code is ( no construction )
This is perfect, thank you so much!
1 Like