Setting up VRHand to pick up objects
Now, we're ready to get our hands grabbing these objects.
Creating a function to find the nearest pickup object
The next thing we need to do is find out what objects are near enough to our hand to be picked up. Let's create a function to do this:
- In
BP_VRHand
, create a new function calledFindNearestPickupObject
. - Set its
Category
toGrabbing
and itsAccess Specifier
toPrivate
. - In its implementation graph, right-click to create a
Get All Actors with Interface
node, and set itsInterface
value toBPI_PickupActor
.
This is going to give us an array of every actor in the scene that implements the BPI_PickupActor
interface.
- Drag a connector from the
Out Actors
output and create aFor Each Loop
node:
We're going to iterate through the actors that could possibly be picked up, ignore any actor that's too far to be considered, and then return the closest remaining eligible actor.
- From the
For Each Loop
Array Element
output, drag out a connector and callGet Actor Location...