How to Pick Up items when Player Look for it and press Action Key

Hi guys,

My question is about pick up item like RPG game

For example:

In Scene a player found some item and wants to pick up,
A hud shows “Press ‘Action Key’ for pick up” and pressing Action Key this item is added in his inventory.
But this is only possible if the player is looking at the item

I found this event “ReceiveActorBeginOverlap” for physics objects, but only works if Character overlap colliders


I found another solution with Raycast in Tick Function

FHitResult rayHitResult;
UWorld* World = GetWorld();

if(World->LineTraceSingle(rayHitResult, WorldFVectorStartPosition, WorldFVectorStartEndPosition, ECC_WorldStatic, TraceParams))
ActorItemWaiting = *rayHitResult->Actor;

and in BindAction function for Action Key

if(ActorItemWaiting != NULL)

is this a best solution?

Yep, that sounds like the correct approach!

You may want to consider using an ‘Interface’ that all ‘interactable’ Actors implement, which would give you a consistent way to interact with different types of objects.

I actually have that Victor's Use System[Tutorial] - Community Content, Tools and Tutorials - Unreal Engine Forums

thanks for your help guys! were very helpful :slight_smile:

that’s what I needed

I’m considering to use an Interface solution too