Handing Item Drop/Pickup

Hi there,
Currently im working on a Item system for my game and i want the character to be able to pickup and drop items at the moment, i do this the following way,

My Item is a blueprint based on (c++)MyItemClass which is based on AStaticMeshActor, and i have 1 blue print per every item.

when Item is picked up, i add it to the Players inventory and then i set the Items StaticMeshComponent->SetStaticMesh(NULL);

when the player drops the item, i set the Items position to front of the character and do StaticMeshComponent->SetStaticMesh(Mesh); (i assign Mesh in Item::BeginPlay() by doing Mesh = StaticMeshComponent->StaticMesh)

is there a better way of doing this? will this impact the performance in any way?

I’ve tried to do StaticMeshComponent->DestroyComponent() when i pick the item up , but i have no idea how to recreate the StaticMeshComponent once i drop the item , and how to get a functioning reference to the original static mesh, the item is using.
I’ve tried to follow quite few tutorials on how to create a StaticMeshComponent on runtime, but i either have a problem getting the original mesh, or the item doesn’t appear in the world.

Any help would be much appreciated

Hi,

I’ve dealt with this issue before, to be honest I haven’t decided on what is “best” and I’ve seen people using different approaches.

For player inventory I decided to split the items into multiple blueprints, one for in-world the other for in-inventory. This does build up to a lot of blueprints in the basic implementation, but you would probably end up using a DataTable once your item size grows beyond just a few.

Here is how I did my inventory system: http://www.tomlooman.com/tutorial-basic-inventory-system-in-blueprint/
I’d say this isn’t perfect and I might make adjustments as the system expands (for example DataTables would have a big effect on this system and keeps number of unique BPs to a minimum)

More info on datatables: