Add VR hand and Anim to VR Pawn (Part 1)

Object Specific Grip States (Part 2)



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
image.png
Click on the wheel icon, select show all bones:
image.png
Select Root Bone, Add shape, Add Box
image.png
scale and adjust the box that fit the gun handle:
image.png
Select the main (top one) Root Bone again, add another box, adjust this fit the main part of gun
image.png
image.png
Then add 2 more capsules to cover the rest of the gun:
image.png

Setup Grab Enum to add new grab types


In VR template, Blueprints, open GrabType Enumeration
Add 2 new Enumeration, name as pistol and melee
image.png

In Hands Asset, open QK Custom Hand Skeleton, R click on top Hand_r, add socket,
rename as Pistol_Socket
image.png

On pistol socket details, change preivew controller and animation to Use specifican animation, and Anim QK gunhold
image.png
R click on pistol socket, add preview Asset, type blaster (blaster will be added in hand preview, but disoriented)
image.png
still on pistol socket, adjust the pistol to correct positon on hand
image.png
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)
image.png
Repeat the same on right hand from creating on cast to VR pawn, then connect as follow
image.png

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
image.png
Connect Pistol and Melee to them:
image.png

On Pistol nodes, Set, add nodes as follow:
image.png

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
image.png
Rename in Details of Output return value
image.png
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
image.png

Copy pistol_socket typing (make sure no typo, as it’s case sensitive) in Handskeleton, then paste in Socketname in marcos:
image.png
image.png

Create get Right hand anim node, connect to Set Object Type node, set type to gunhold, connect to location and rotation node:
image.png

Repeat the same on left hand by copy all 6 nodes below, replace right hand ref and anim to left one:
image.png
Connect to Switch on EC controllerhand:
image.png

Duplicate both left and right hand newly created nodes from pistol, apply on melee as well:
image.png

Replace the socket names and the object type value (from gunhold to knifehold):
image.png

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:
image.png
Create following nodes on end nodes of hand drops SET:
image.png

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
image.png
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
image.png
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
image.png
Go back to Hand BP, AnimGraph,
Open State machine, then open Object state
image.png
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
image.png
connect as follow and save:
image.png

Now the hand animate will be varied depends on what object grabbed on hand
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.