Import weapon blade and gun from project
Fix the gun physic asset:
Open the mesh phsyics assets
R click on the Root Bone, delete the capsule
Click on the wheel icon, select show all bones:
Select Root Bone, Add shape, Add Box
scale and adjust the box that fit the gun handle:
Select the main (top one) Root Bone again, add another box, adjust this fit the main part of gun
Then add 2 more capsules to cover the rest of the gun:
Setup Grab Enum to add new grab types
In VR template, Blueprints, open GrabType Enumeration
Add 2 new Enumeration, name as pistol and melee
In Hands Asset, open QK Custom Hand Skeleton, R click on top Hand_r, add socket,
rename as Pistol_Socket
On pistol socket details, change preivew controller and animation to Use specifican animation, and Anim QK gunhold
R click on pistol socket, add preview Asset, type blaster (blaster will be added in hand preview, but disoriented)
still on pistol socket, adjust the pistol to correct positon on hand
R click on pistol socket, remove all attached assets
Go back to hand_r skeleton again, add new socket, name as Melee_Socket,
repeat the same step to fit the cleaver fit the hand, after change QK hand animation to KnifeHold
Add functionality to grab component snap in hand:
Go to VR template BP, open Grab Component BP class, event graph
From Set collision profile name node, add the following new nodes:
(Lefthand Ref and LeftHand Anim are renamed from promote variables)
Repeat the same on right hand from creating on cast to VR pawn, then connect as follow
Open TryGrab function event graph, unfold Switch on Grab Type node, can find Pistol and Melee:
copy the 4 nodes from Disable physics.......controller, paste twice at blank space
Connect Pistol and Melee to them:
On Pistol nodes, Set, add nodes as follow:
Add Macros to speed up the applying socket value process:
click + button at Marcos on L hand side (new event graph formed), create as follow
Rename in Details of Output return value
Name the new marcos to GetSocketLocationandRotation
Back to TryGrab function, add Right hand Ref and connect with GetSocketlocationandRotation marcos, connect to set world locaiton and rotation node
Copy pistol_socket typing (make sure no typo, as it’s case sensitive) in Handskeleton, then paste in Socketname in marcos:
Create get Right hand anim node, connect to Set Object Type node, set type to gunhold, connect to location and rotation node:
Repeat the same on left hand by copy all 6 nodes below, replace right hand ref and anim to left one:
Connect to Switch on EC controllerhand:
Duplicate both left and right hand newly created nodes from pistol, apply on melee as well:
Replace the socket names and the object type value (from gunhold to knifehold):
Set up logic for when want to drop our objects:
Open Try release Function event graph
In Switch on Grab type node, connect pistol and melee to the reroute node:
Create following nodes on end nodes of hand drops SET:
Create actual BP for gun and Melee:
Duplicate grabbale small cube BP, rename as BP_QK_Blade
Replace the mesh to Cleaver in viewport, scale up to 1.0
In GrabCompoent, change grab type to Melee
Place the mesh in the scene
Repeat the same step by duplicate Pistol BP to BP_QK_Blaster, an extra step is:
In MuzzleLocation component, relocation the muzzle on the gun and rotate 90 degree
Grab type to Pistol
Place in scene too
Open Hand BP, leave it there first
In hand folder, create Blendspace 1D, choose QK Customhand skeleton, name as BS_ObjetAnim, open it:
Set Hoziontal axis max value to 2
Drag knifehold anim in 0, gunhold to 1, QK grip to 2, type the value on blend sample column on L hand side, if those values are not exactly as 0, 1, 2
Go back to Hand BP, AnimGraph,
Open State machine, then open Object state
Replace the Anim RQ grip (created in Part 1), with BS object Anim (1D blend)
Drag Objectype variable in graph, type to float to create a dot node
connect as follow and save:
Now the hand animate will be varied depends on what object grabbed on hand