Make an object “pickupable” and throwable in VR in Unreal Engine 4
Last week we started working on our interactive VR loft.
As a first step, we wanted to make the chair objects moveable and enable the player to pick them up and place them somewhere else or even throw them.
We knew it had something to do with collision and pyhsics and getting the controller hooked up.
Also, we knew we could probably just copy the pickup cubes from UE4’s built-in VR template.
So that’s what we actually ended up doing and it works great!
You have the Player object set up to process the trigger as pickup action.
In our case, we simply used the “VRPawn” object from the Unreal VR template.
Step 1: create a new project based on the Unreal VR template
We already did some work on the template and imported our loft 3D-model as well as placed some foliage as you can see below.
Step 2: find the pickup cube object (e.g. just click on one of the blue cubes in the viewport)
Step 3: duplicate it (e.g. right-click > edit > duplicate or alternatively ctrl+w)
Step 4: replace the mesh with the one you want to use (if you haven’t imported it to your scene yet, this would be the time). You will probably have to adjust the scale and rotation at this point. (the chair in our scene here is too small and upside down, hanging in the air).
Also, if your desired object has its own material, replace the PickupCube’s material with the desired one.
Step 5: double-click on the mesh preview / thumbnail / square-format-image in the details panel to open the mesh editor
Step 6: select simple collision from the collision dropdown. This toggles visibility of the collision mesh, which will be laid over as a green wired mesh.
Step 7: If you already have a collision mesh in place and are happy with how precise it encloses your object’s shape, move on to step 8. If not, create a new collision mesh with collision > auto convex collision.
The parameters will show to the right under the details panel.
Usually the default settings are fine and you can just click “Apply”.
If you don’t like the resulting collision mesh, you can delete it, adjust the parameters of the auto convex collision and apply again. Repeat until you are satisfied with the result.
Step 8: Click save in the mesh editor.
Step 9: This is it. If you hit play now, you should be able to pick up objects and throw them around, place them on other collidable objects, and so on…