Home › How do I…? › How to make an object grabbable in VR and on desktop

How to make an object grabbable in VR and on desktop

Advanced Framework Pro makes an object grabbable with one component, BPC_Interaction_Grip_Pickup, plus grip sockets that say where a hand attaches. The same setup works for VR hands and for mouse drag on desktop. By the end of this you will have an object a player can pick up with either hand, in VR, and drag on desktop.

At a glance

Your actor (needs a collidable mesh)
├─ BPC_Interaction_Grip_Pickup   Highlight Class = BPC_Highlight_Material, Highlight Color,
│                                Max Attach Distance, Required Prefix (optional)
├─ BPC_Socket_Grip "Grip_Left"    one per hand position, name prefix Grip_
├─ BPC_Socket_Grip "Grip_Right"
├─ BPC_PickupCoordinator          two-handed objects only
└─ BPC_Replication_Actor          multiplayer only
Events: On Gripped Start, On Gripped Release    Veto: Interface_Grip › CanBeGripped = false

Steps

  1. Open the actor Blueprint you want to make grabbable. It needs at least one collidable mesh component.
  2. Add a BPC_Interaction_Grip_Pickup component.
  3. Set Highlight Class to BPC_Highlight_Material and choose a Highlight Color so the player gets hover feedback.
  4. Add one or more BPC_Socket_Grip components and position them where a hand should attach. Keep the Grip_ name prefix.
  5. Add a BPC_PickupCoordinator component if the object should support being held by two hands at once.
  6. For multiplayer, add a BPC_Replication_Actor component.
Adding the grip interaction component
howto_grabbable_01.pngAdding the grip interaction component
Adding the grip interaction component
Placing grip sockets on the mesh
howto_grabbable_02.pngPlacing grip sockets on the mesh
Placing grip sockets on the mesh
The finished result — the object held in the hand
AFS_UX_Grip_pickup.pngThe finished result — the object held in the hand
The finished result — the object held in the hand

Notes

The closest valid socket wins when several are in range, scored by distance within Max Attach Distance. Set Required Prefix on the interaction if the object should only accept particular sockets.

Bind to On Gripped Start and On Gripped Release on the interaction component to react.

To let players grab with the trigger as well as the grip button, see Grab with the trigger.

Implement Interface_Grip on the actor and return false from CanBeGripped to veto grabbing under your own conditions.

Multiplayer

Without BPC_Replication_Actor, other players will not see the object move. The replication component handles interpolation and authority hand-off automatically when a player picks it up.