Hello @Headless888 ,Welcome to the forums!
In this example, I used a Sphere Collision component as the reference object. First, I applied the following settings in the Details panel, under the Collision section. Then, I replaced the DefaultSceneRoot with the Sphere Collision component, making it the new Root Component, as this helps prevent collision issues later on.
Next, I applied the following settings to the Static Mesh (in this case, a sphere).
Inside the Event Graph, we’ll create a Boolean variable called bIsGrabbed and two Custom Events: one for the Grab logic and another for the Drop logic.
( If you don’t want the object to have physics, simply remove the
Set Simulate Physics node.)
Both events will have an input that stores a reference to our character. In this example, I’m using the Third Person Template, so the input type is BP_ThirdPersonCharacter Object.
OnGrab
OnDrop
After that, we’ll create two Input Actions, one for Grab
and one for Drop,
and add them to the IMC_Default. In this example, I used the same key for both actions: pressing the key once grabs the object, while holding it for 0.2 seconds drops it. If you prefer, you can also use two different keys and set both Input Actions to use the Pressed trigger.
Then inside BP_ThirdPersonCharacter, we’ll create two variables: a Boolean called bHasObject, and another variable that stores a reference to the object currently being held. This ensures that the player can only hold one object at a time. In my case, I named it CurrentObjectInHand, and its type is BP_Object, which is the name of the object’s Blueprint.
Next, we’ll create two Custom Events that will be responsible for calling the events we previously created inside BP_Object.
To finish, we’ll add the corresponding logic to each Input Action. For the Grab action, we’ll perform a Sphere Trace to detect and interact with the object. If the trace hits a BP_Object, we’ll call the Grab event. On the other hand, if the character is already holding an object, we’ll call the Drop event to release it.
I also recommend checking out this video, which explains another way to create a Pickup, Carry, and Drop System that you might find useful.
Hope it helps!