Download

Stumped on simple inventory

Hi,
Hoping someone can fill in gap in my knowledge as this has me stumped. I am developing a game with a simple inventory (3 inventory slots in which you can place items which the user can pick up - think a bit like the dizzy games). The items are BP Actors and have some instance variables (like a string for name to show to the screen or to identify the colour of the pickup). For my inventory I used an array of the parent BP_pickup actor I created.

To get this working I intended to use a collision box and a keyboard input to put the overlapped actor into one of the 3 free array slots, show the name to the screen in the HUD (this is persistently there) and then destroy the original actor from the level, then later I could place it back down again by spawning in a new copy and copying the variable data across…or so I thought. However, when I destroy the original, it also (eventually) destroys the one in the array as well, I assumed it would clone it, but alas no…

Originally I used an array of Actor Class references and that worked perfectly, but soon realized that when I dropped(spawned) the object back down I had no instance data to put there with it.

The only other thought I had was to teleport it an insane distance away rather than destroy it, but surely there is a better solution?

cheers
Magnus

Never mind, fixed it! a more creative use of spawn actor on the pickup and drop functions did it :slight_smile:

turns out I do need help! my creative use of spawn comes with the additional issue of needing a transform so the object still appears in game. Can I spawn an object into the game without a transform? I know I could set it hidden at 0,0,0 and then assign it to my actor array but that seems not very efficient.

cheers