Home › How do I…? › How to grab with the trigger as well as the grip button in VR

How to grab with the trigger as well as the grip button in VR

In Advanced Framework Pro the grip button grabs by default. Players who reach for the trigger instead can be given both: you add the trigger to the grab input and take it out of the context that passes buttons to held objects. Everything happens in copies of four input mapping contexts, so the framework itself stays untouched. By the end of this either button picks an object up, and letting go of that button drops it.

At a glance

Your copies of AFS_UX_Grip/Input/VR
├─ IMC_VR_Hand_Grab_Default_Left / _Right       + IA_VR_Grab_* ← (L)/(R) Trigger keys
└─ IMC_VR_Grabbed_ButtonForward_Left / _Right  − IA_VR_ButtonForward_Trigger_* Trigger rows
                                               (keep the TriggerAxis rows)
Motion controller Blueprint › BPC_ControllerAbility_Hand_Grab
├─ Mapping Contexts Default       = your two grab copies
└─ Mapping Contexts ButtonForward = your two ButtonForward copies
Result: grip or trigger grabs; releasing the button you grabbed with lets go

Steps

  1. In the Content Browser, open AdvancedFrameworkPro/AFS_UX_Grip/Input/VR and copy four mapping contexts into a folder of your own: IMC_VR_Hand_Grab_Default_Left and _Right, IMC_VR_Grabbed_ButtonForward_Left and _Right.
  2. Open your copy of IMC_VR_Hand_Grab_Default_Right. Click + next to Mappings, pick IA_VR_Grab_Right as the action, and in the key selector pick Oculus Touch (R) Trigger. Add Valve Index (R) Trigger and Vive (R) Trigger the same way if you support those controllers. The keys go into the mapping context; the input action itself stays untouched.
  3. Do the same in your IMC_VR_Hand_Grab_Default_Left copy with IA_VR_Grab_Left and the (L) keys. Save both.
  4. Open your copy of IMC_VR_Grabbed_ButtonForward_Right and delete the rows that map IA_VR_ButtonForward_Trigger_Right to a trigger key. Leave the Trigger Axis rows alone. Do the same in the Left copy and save both.
  5. Open the motion controller Blueprints that carry the hand grab ability, BPC_ControllerAbility_Hand_Grab. In the examples these are BP_MotionController_Hands_Left_Showroom and _Right_Showroom.
  6. Select the ability component and set Mapping Contexts Default to your two grab copies and Mapping Contexts ButtonForward to your two ButtonForward copies. Compile and save both sides.

Notes

Why step 4 matters. While a hand holds something, the framework adds IMC_VR_Grabbed_ButtonForward, which passes button presses on to the held object. It also listens to the trigger and consumes it. Without step 4 the trigger goes to the held object as soon as you grab, so the grab never sees you let go: the trigger works once, and only the grip can release.

Objects that use the trigger themselves, like the example pistol, do not mix well with trigger-grab: releasing the trigger after a shot would drop them. Keep them on grip, or keep the trigger in their ButtonForward context.

An AI assistant connected to the editor can make these changes for you; see Working with AI assistants.