Possible make a list to hold all the overlap actors?

Hi!

I am been working, trying out and figure out how to make and create a script within my player model on how to pick up and drop items. And with the testings that I have done, it have now worked. Even made so the animation works as well when grabbing and holding the items.

But as I now started to wanna experiment and try out, is it possible that(for example: ) When I press E, depends on which item I am looking at to press E on, will be picked up. But because there will be(another example) 60 different models/objects that I want to be able to pick up. I want so that each object(which will have their own animation connected to it) will work.

On the picture that I will show, I have been using a Knife model to just work and understand the idea how the script for picking items up works:

Also some context, I have made so when I press E on the knife, a script on the knife will start. By deleting the actor from the level. So it will then appear in my hand. And I use a Enumeration for it(which is also connected to the animation).

And when I press Q(to just see how it works when wanna drop the item) I spawn the item back in.

There’s a function you can use called Sphere Overlap Actors.
You could build a list of those, and then use “Find Nearest Actor” to determine which one is closest to your point of origin (That being your player, your mouse-cast-to-world, a motion controller, or whatever else.)

Here’s an example, used for finding grabbable objects in a VR project.

One of the benefits of this approach is that you can dictate a world-position to reference from, and you can play around with the range by altering the Sphere Radius value.

Oooo? Then would you recommend, if we would use the picture from what I am showing for the pick up part, do I add the “Sphere Overlap Actors” to change it out against the “For Each Loop With Break” component? Or do I just connect the “Sphere Overlap Actors” to the “For Each Loop” component?