The easiest way would be to go with TriggerVolume attached to Pawn and check whether an Actor overlaps it. But that has many disadvantages:
- We would have to check if the Actor is “Grabable”, so something like “hasComponent(GrabableComponent)”
- It would trigger with all Actors in the scene, which is deffinitely not what we want
- If we were overlapping more Actors with our “Grab Volume”, there would be no way of determining which one we want to grab
So better way would be to have “GrabSystemComponent” attached to Pawn and each Tick (or on KeyPress) send RayTrace and ask for “Actor in line”, then again ask if the Actor is “Grabable” (Maybe RayTrace can ask for something different than just AActor, dunno yet) I think RayTrace is resource-cheaper because the engine should be optimized for it as certainly many are done while rendering? (just assuming)
“GrabableComponent” could have something like “weight”, “canBeGrabbed” so it would prevent player from grabbing it at certain conditions or allow it based on some action done etc.
“GrabSystem” could have registered the grabbed object and have methods like “Grab(GrabableComponent)” and “Release(GrabableComponent)”