Is it possible to have inventory item and pickup item in the same class?

Hello, i would like to know if it’s possible to have an inventory item (with number of rows and columns, the texture to draw when the inventory is shown in the hud) with the physical representation of the pickup in the same class. I tried to create a WeaponItem class and then created a blueprint that derived from that with a static mesh to represent the pickup. The problem is that once the player picks up the item in the world i can’t destroy it, because i need that instance to go to the inventory, is there a way to let the item only live in the inventory once it’s picked up and not in the world anymore? I believe that UT uses a different class for the pickup (placeable) and the item (non-placeable) itself, when the character overlaps the pickup he spawns a new WeaponItem and adds it to the character inventory, is that the right way to do it? Thanks

No UT uses exact same class for pickup and inventory, this is how inventory worked in all UE game games since very beginning (Unreal 1) and it’s recommanded way to do inventory in UE

Actor class does not no have any physical form by it self, that physical form are composition of components, so if you want you Actor lose physicality you simply remove component and to return physical form you add component back, but all this time Actor instance is still there and you can use it in inventory, for easiness you can simply make component invisible.

I think the thing that makes me more confused is the fact that i have a transform (with location, rotation and scale) for an inventory item that does not have a physical form, but i will try what you suggest. Can you tell if it’s also possible to have the Weapon Skeletal Mesh and Weapon functionality also there, or that should be a separate class, i’m just trying to group things as much as possible.

Look on core functions and figure yourself :stuck_out_tongue: you can put to class whatever you like and you can code it whatever you like, it’s C++. You can make property “Weapon Mesh” which can be used both in pickup component and in hand component (added to character).

I’ve looked into Actor.h and it had a GetTransform() so i thought that Actor stored a Transform, but looking into the Actor.cpp i saw that he tries to get the root component transform value, so it should be good. I know i could do that, but usually they use static meshes for the pickup and skeletal meshes for the weapon itself, but i can try using the Skeletal Mesh as pickup. Thanks for all the help :slight_smile:

I’m trying to disable the Component without removing it, because i might thow the item again to the world as a pickup. Is there a way to do that without setting visible false and disabling collisions? I tried to use the SetActive(false), but it didn’t do anything so it should serve some other purpose. I’ve been investigating and UnregisterComponent() seems the best candidate, do you agree?

Look like a good way to go to me too, try it out :slight_smile: