Unity tutorials - hand presence and interaction in VR
https://learn.unity.com/tutorial/unit-5-hand-presence-and-interaction/?courseId=5d955b5dedbc2a319caab9a0&tab=overview&uv=2018.4#5d955988edbc2a23122a1e7d
- Create hands in VR
- Search CustomHandLeft and Right.
- Drag Left onto TrackedAlias>LeftControllerAlias and the same for the right.
- Look at the inspector for CustomHandLeft. Two scripts are visible. Retain enable for Hand Script. Disable 'OVR grabber' as the VRTK is going to do the grabbing
- Cubes are no longer required. Do not delete, just disable by unchecking mesh renderer in the inspector
- These hands are not in the right layer. VRTK will cast rays for the locomotion created in the locomotion and ergonomics tutorials. These rays will hit the hands and we will not be able to teleport anywhere.
- Select hand>inspector>layer>ignore raycast>yes to change children prompt
- Save
- Test in VR
- Recording below
- When creating custom hands, make sure that your virtual hands align correctly with real-world hands. This is known as 'hand registration' and helps with immersion. Test by putting on the head mounted display (HMD) looking through the nose hole at VR hands and real hands simultaneously, by moving the HMD up and down. See if they line up. Also put real-world finger on the back of the hand, poke fingers together to see if they line up. If they don't then there is a problem with hand registration. My hands look roughly ok in the editor, but when trying the back of hand finger test and finger tips touching, my fingers were out by about an inch. This is accounted for by different finger lengths etc. If they missed each other entirely then there would be a problem with hand registration . The other method for hand registration involves dragging a known object (in this case the touch controllers) into the editor.
- Find OculusTouchForQuestandRiftS_Left and Right
- Drag onto LeftControllerAlias and RightControllerAlias respectively.
- Use the move tool to move them apart to clearly see if they are lined up correctly
Interacting with the world
- Assets> VRTK interactor prefab
- Drag onto LeftControllerAlias and Right respectively
- Go to hierarchy>Interactor>ColliderContainer>ExampleAvatar (rectangular object)>inspector>disable mesh renderer to make it non-visible. Do for both left and right
- Wire up the Oculus API (application programming interface) to talk to the VRTK grab system. Confusing but don't worry
- Hierarchy>InputHandlers>create a new empty game object>rename GrabButton.L>duplicate>rename R for right
- Add component in the inspector and add OVRInputAxis1DAction to each
- Add component in the inspector and add Float To Boolean (script)
- Float To Boolean>positive bounds>set to 0.75. This is how much the hands can grab. If set to 1, it requires a full squeeze to grab which can be uncomfortable and not intuitive.
- OVRInputAxis1DAction>Controller>L Touch and R Touch respectively
- OVRInputAxis1DAction>Axis>Primary Hand Trigger
- Add component Boolean Action for both GrabButton Left and Right
- Wire them up together in the inspector>OVRInputAxisIDAction>Value Changed>Add field>Drag Float to Boolean Script into field>Function>Float to Boolean>Do Transform
- Float to Boolean>Transformed (Boolean)>Add field>Drag Boolean Action (script)>function>Boolean Action>Receive
- Search Interactor Prefab. Add one underneath the LeftControllerAlias and RightControllerAlias (hands) prefabs in the scene. Disable the mesh renderers (cubes) on the ExampleAvatar object in each of the interactor object hierarchys
- Wire up the Oculus API (application programming interface) to the VRTK
- Interactor>inspector>Drag GrabButton L to interactor settings, Grab Action field in inspector.
- Next find an object to interact with.
- Search for interactables in VRTK prefabs
- Project filter locate>Interactable.Primary_Grab.Secondary_Swap prefab (meaning a grabbable object with one hand and swapping to the other hand.)
- Drag Interactable.Primary_Grab.Secondary_Swap underneath the shelf scene object (grey cube) Match the transform attributes to the access_key scene object transform values.
- A large default cube mesh appears. Disable it by selecting Interactable.Primary_Grab.Secondary_Swap>Meshes>DefaultMesh>Inspector>Disable by unchecking box top left
- Duplicate the access_ key and drag duplicate onto the meshes child of the Interactable.Primary_Grab.Secondary_swap
- Disable original key in the inspector
- Go to new key and make sure transforms are set to 0.
- Save
- Test in VR
Now the key needs to be rotated, so it's in a usable direction...
The forward direction is what determines how this is held in your hand.
- select access key: Hierarchy>Environment>PlayArea>Shelf>Interactable.Primary_Grab.Secondary_Swap>Meshes>Access_key>inspector>Rotation Y Axis set to -90.
- We want they key to sit properly on the shelf so we're going to rotate the key, using the Interactable.Primary_Grab.Secondary_Swap. Select Interactable.Primary_Grab.Secondary_Swap in the hierarchy>(a bounding box appears)>select rotation tool using keyboard shortcut 'E'>rotate so the key is upright, with the 'teeth' of the key pointing north and the 'move' tool to pull it away from the book
- Save
- Test in VR
To throw the key
- Project filter and search for: OVRAnchorVelocityEstimator>add to OVRCameraRig/TrackingSpace/LeftHandAnchor/RightHandAnchor/CentreEyeAnchor
- Inspector>OVRAnchorVelocityEstimator
- CenterEyeAnchor -Drag 'CentreEyeAnchor' to 'Tracked Game Object' field
- Drag 'TrackingSpace' to 'Relative To' field
- RightHandAnchor - Drag 'RightHandAnchor' to 'Tracked Game Object' field
- Drag 'TrackingSpace' to 'Relative To' field
- LeftHandAnchor - Drag 'LeftHandAnchor' to 'Tracked Game Object' field
- Drag 'TrackingSpace' to 'Relative To' field
- Go to 'OVRCameraRig'>LinkedAliasAssociationCollection>set the velocity trackers>CentreEyeAnchor to Headset Velocity Tracker>LeftHandAnchor to Left Controller Velocity Tracker>RightHandAnchor to Right Contoller Velocity Tracker
- Find interactors in hierarchy - rename Interactor.L and Interactor.R (can be done earlier in process)
- Select Interactor.L>inspector>Interactor Facade>Drag 'LeftControllerAlias' to 'Velocity Tracker' field. Repeat for Right
- Save
- Test in VR
Comments
Post a Comment