Create BP Interface:
Open a folder called Interface
Create a BP interface, name as Grab, open it
Name the funtion inside as Grab, add variable Motion Controller in Input
Add a new function name as Release, repeat the same on Input
Set Inventory BP with actor:
Create a new folder called Blueprints
Create a BP Class actor, name as InventoryCube, open
Add Static mesh in component, set as Root component
Choose the mesh (cube in this case), collision presets as OverlapAllDynamic
go to Class Setting → Interface, Implement interface, add the Grab
Go the event graph, drag of double click interface release and grab functions in the graph
Create the graph as follow:
In BP folder, create BP class, type StaticMeshComponent, name a InvetnoryComponent. open it
Create the graph as follow:
Remark: BeginOverlap node renaming by Add Custom Event
Continue by adding variables GrabActor, and Controller to Ignore:
For Event Trick:
Remark: Self node by Get a reference by self
Attach inventory to VR pawn For Player:
Open VR Pawn, viewport,
Add InventoryComponentLeft under MotionControllerLeft,
Change it mesh to a sphere, scale down to fit in the camera mesh:
Collision Preset OverlapAllDynamic (to make sure not collide with motion controller)
Duplicate the inventorycomponent for Right hand
Go to Event Graph, end of begin play nodes, add follow:
In InputActipn Grab left and Right nodes, recreate the graph as follow:
Copy all nodes above apply on InputAction Grab Right, change motioncontroller, GrabActor (duplicate from Grableftactor) variables from left to right
Drag the InventoryCube BP in the scene, open VR preview
Now can snap the inventory cube on Vr component (controllers), can create other inventory elements besides cube to snap on the component/actor/character