How can ı make a pick up system with line trace in UE4

Hello, how can I make a pick up system like in Hello Neighbor using blueprint and line trace in UE4?

Hello, In fact, everything is quite simple, there are many training videos on YouTube about the item selection system. Including you can provide any similar training video for version 5 of the engine - the logic itself does not change in any way.

You need to create a main actor (blueprint) of objects that can be picked up and add a collision to it (for example, a sphere), make it invisible during the game, and also disable collision with the player. Once you have set up the collision, you can create child actors based on this actor for each interactable item.

You write the general logic in the original pickup blueprint (for example, in BP_PickUpMaster), but if some of your items have their own functionality, you should write it in the child pickup blueprint of a specific item.

In the line trace you get Hit Actor, check if it is equal to yours BP_PickUpMaster (the code name of your main blueprint pickup actor), if yes, then save it in a variable of the same type BP_PickUpMaster, and also visually change the player’s sight (if you want to make a complete analogy to the Hello Neighbor game).

If the line trace did not fall into the interaction object (pickup), then you clear this variable (set an empty value).

Next, in the Interaction Event (for example, when pressing the E key), you check if this pickup is valid, if so, then you remove the pickup actor (call Destroy Actor Event) and give the item to the player, for example, through the Spawn Actor of Class, after which you bind it to the player’s hand through the Attach Object to Actor.

That’s all, your system completed.