Picking up items to separate hands

Hi all, still pretty new and learning Unreal. I’m trying to create a pick up and throw system with both hands. For example you find an rock and use the pick up key (E) and it goes to your right hand, when you find another rock you use pick up again and because one is already in your right hand, it goes to your left. After both hands are full you cant pick up anymore. I’ve gotten to the point where you can pick up multiple rocks, however as they’re both the same item they just all go to the right hand. I’m assuming (and hoping) there’s some other way to handle this than just making hundreds of duplicate but differently named rock actors to spread around the map, I just can’t figure it out.

This could be handled a myriad of ways, and not knowing much beyond the question I will simply address the hand switch issue. A really simple to check against which hand is being used is creating an enum switch like this.

And you just run whatever command you want from there. Hopefully this covers what you’re actually stuck on or at least points you in the right direction.

To check if you can carry stones you should add a CurrentInventory and a MaxInventory variable of type integer to your player (for me this is in ThirdPersonCharacter).

Why both? With MaxInventory you say “I can only carry 2 stones, not more”. Whenever you pick up a stone you increase your CurrentInventory by 1. So you can only pick up stones as long as CurrentInventory is less than MaxInventory.

When you want to carry your stones in your hands, you need to add sockets to your skeletal mesh (SK_Mannequin for me). Open the skeletal mesh and, for example, add a socket to middle_01_r and middle_01_l with RightClick => AddSocket.

Those stones are going to be a Blueprint of type Actor. In this Blueprint add a StaticMesh (AddComponent), drag it on DefaultSceneRoot to overwrite it and add a BoxCollision as a child of the StaticMesh. The StaticMesh should be your stone (choose it on the right side, for me it is the 1M_Cube at a Scale of 0,25 in x,y,z) with a CollisionPreset of type OverlapAll. The BoxCollision should be big enough, so choose a Scale of 7-8. For the function/event that is going to be triggered, go to ClassDefaults and set AutoReceiveInput to Player0. In your EventGraph of your Stone Blueprint add this:

The Stone in these pitcures is my renamed StaticMesh. Drag it from your component list and drop it in your EventGraph. For your Keyboard E Event you have to set ConsumeInput to Disabled (select the event and go to input on the right side). To add the OnComponentOverlapEvents click on the BoxCollision in your component list and add the Events from the right side (green buttons at the bottom).
What is happening in the Blueprint: When your character overlaps your Stone(you have to place it in the level) the OnComponentBeginOverlap will be triggered and the IsOverlap will be set to true. When you press E you will get a reference to your Player. After that you have to check can you still pick up stones and are you in the overlapping area. If this is true and this is your first stone, disable collision (causes weird behaviour in your hands), attach it to one of the sockets and increment your CurrentInventory. If you already have 1 stone, the same will happen but for the other socket in your other hand. If your CurrentInventory is equal to your MaxInventory nothing will happen (that’s up to you to add it in).

1 Like

this worked perfectly, much appreciated