Inventory pickup class storage
I'm working on the inventory system and came up with the question. Say, all pickup items are various children of base pickup class and one item placed in the world was picked up by a character. How does storage of an item would work? I can imagine item having an inventory slot number integer that would be set upon pickup. After item is picked, it simply gets hidden and it's collision gets disabled so item is not visible in the world. If item is needed to be dropped from inventory, it just gets visible and collidable again with updated drop location. I guess, that would work, but what if new level is loaded? Loading new level would destroy an item and there would be no way to drop it back because dropping is just a re-positioning an item. Coolest way would be to destroy an item upon pick up and just store it's type in item slot unit. If item needs to be dropped, it gets casted to a stored type and is spawned in the world. I have no idea how to make a type storage without using if's and strings. (i.e. if string is "ball", cast to ball_type). Sorry for a wall of text.
asked Oct 04 '15 at 10:24 PM in Blueprint Scripting
That's actually fairly easy.
You don't need the type of the class. It's not important to know what the name is. What do you need to spawn something? The type or how it's more often called: The class.
So what you need to save is the class of your actor / item object which you find via a simple "Get Class" from your object reference.
Follow this question
Once you sign in you will be able to subscribe for any updates here