Grab Component in VR template

Two Handed Grab



(concept: make a gun rotated, looks like attach on each hand, not literally attach on each hand)

Set the grabbed object gripping position:


Open FP Gun mesh, skeleton tree
change grip point rotation x to 45
image.png
On Grip_Bone, R click, add a socket, name as SecondaryGripSocket
set X and Z location as 35, 5
image.png

Open a folder called interface,
create a BP interface called Grab
image.png
Create 2 functions, name Grab and Release, add motioncontroller input
image.png

Set Gun BP:


Create another folder called Blueprint,
add a BP actor, name as Gun
add skeletal mesh (choose the gun mesh), and 2 sphere collision, name as follow
image.png
Choose Gripoiint on parent socket on main grip collision component
And secondary grip on secondary component
image.png
image.png
Reduce both sphere radisu to 13, so both grips point wont’ be overlap on the gun
image.png
Go to Class Settings (top menu), add the Grab interface just made:
image.png
Go to Event graph, leave event tick behind, R click on both interfaces, implement event (to create their nodes in graph)
image.png

For Grab Main and Secondary BP:


Set below (to check if motion controller pass through, is within the main range of grip collision)
image.png
Promote event grab motion controller to variable, then rename as Main Grip Controller
image.png
Continue below (to let socket transform rotate to the value based on what we set in gun skeletal
image.png

For Secondary Grip collision,
set the branch at false with the other branch, so to be sure impossible for 1 motion controller set for both main and secondary grip points
image.png
Duplicate first few nodes to secondary grip, use the reroute point to promote variable, name as Secondary Grip Controller
(only main grip be valid first, before consider secondary grip)
image.png
Final:
image.png

For Release BP:


Set below, convert to validated get of the mian grip controller
image.png
Continue the validated get node as below (to be sure main grip is reattached if valid, same as the end of grab BP; if not valid, main grip still hold even secondary grip is released)
image.png

For Event tick (to control rotation of gun to look like attached on hands, when both grips valid):
image.png
Continue to make the correct rotation:
image.png


To modify VR Pawn:


Drag Input Grab Left and Right nodes away
On left grab node:
image.png
contiunue at this
image.png
Get Left Grab actor, get validated, connect to Released output, finish at this:
image.png

Duplicate the essential nodes to Grab Right input,
replace left to right controllers
promote to variable on reroute node, name as RightGrabActor
image.png

Drop the Gun BP in the scene
Test the game, need to grab main one first, then grab secondary

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.