(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
On Grip_Bone, R click, add a socket, name as SecondaryGripSocket
set X and Z location as 35, 5
Open a folder called interface,
create a BP interface called Grab
Create 2 functions, name Grab and Release, add motioncontroller input
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
Choose Gripoiint on parent socket on main grip collision component
And secondary grip on secondary component
Reduce both sphere radisu to 13, so both grips point wont’ be overlap on the gun
Go to Class Settings (top menu), add the Grab interface just made:
Go to Event graph, leave event tick behind, R click on both interfaces, implement event (to create their nodes in graph)
For Grab Main and Secondary BP:
Set below (to check if motion controller pass through, is within the main range of grip collision)
Promote event grab motion controller to variable, then rename as Main Grip Controller
Continue below (to let socket transform rotate to the value based on what we set in gun skeletal
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
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)
Final:
For Release BP:
Set below, convert to validated get of the mian grip controller
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)
For Event tick (to control rotation of gun to look like attached on hands, when both grips valid):
Continue to make the correct rotation:
To modify VR Pawn:
Drag Input Grab Left and Right nodes away
On left grab node:
contiunue at this
Get Left Grab actor, get validated, connect to Released output, finish at this:
Duplicate the essential nodes to Grab Right input,
replace left to right controllers
promote to variable on reroute node, name as RightGrabActor
Drop the Gun BP in the scene
Test the game, need to grab main one first, then grab secondary