Mapping touch controller buttons

Although we used the X and A buttons, feel free to use whichever button combination works for your situation. The Unity documentation has a complete mapping for the Oculus, Gear VR and Vive controllers at https://docs.unity3d.com/Manual/OculusControllers.html. The mapping contains the name, interaction type, and ID of each button. These values are needed to tell Unity how to handle button inputs.

Depending on your version of the OVRPlugin or Unity, the Teleporter script may not work as expected. You may also have to add input settings for the controller buttons. Perform the following steps below to map the controller inputs:

  1. Select Edit | Project Settings | Input from the main menu.
  2. The Inspector panel now displays the button mapping for Unity. If the list is empty, try clicking on the Axes title to expose the option.
  3. If Button.One is not present, duplicate one of the existing entries and change the values to match those in Figure 7.16. Be sure to match the text exactly; include capitalization, spacing, and drop-down values:
Figure 7.16: Adding array elements for Button.One and Button.Three
  1. Select the LocalAvatar GameObject.
  2. The script required two variables. Drag the TeleportTarget GameObject to the target variable. Set the layer mask to TeleportTrigger.
  3. Before testing the script, move the Tracking to Position (0, 1.8, -6) Rotation (0, 0, 0).

If we tried to play the scene right now, everything would work, except that the teleporter would teleport us below the TeleportArea GameObject. This is because our OVRCameraRig is tracking the player's position based on the camera's eye level. We can correct this issue, by changing the tracking type:

  1. Select the OVRCameraRig GameObject and view the OVR Manager (Script) component. Under the Tracking heading there is an attribute for Tracking Origin Type. Change this value to Floor Level.
  2. Play the scene.

The teleportation target should follow your gaze as you look at the TeleportArea (1) GameObject. And when it is visible, clicking the X or A button will teleport you to that location. Expand the teleport range by duplicating and increasing the TeleportArea (1) GameObject.

  1. Create two or three duplicates of the TeleportArea (1) GameObject. Arrange two of the objects to provide access to the Wacky Mole and Bottle Smash booths. But you can also add others to let the player move about the scene. Figure 7.17 shows a simple layout of the GameObjects. Use the following list when considering teleport locations:
    • Choose locations that provide areas of interest to the player.
    • Keep teleport areas at ground-level.
    • Avoid overlaying any of the teleport areas. In some instances, this causes flickering and visual artifacting across the scene.
    • There is considerable scientific debate on what happens when atoms are instantaneously teleported into the same space. The leading theory is that the overlap of electron clouds would produce a very large and potentially messy, nuclear explosion. So just to be safe, avoid teleporting players into any solid objects.
  1. Deactivate the Mesh Renderer for each of the TeleportArea (x) objects. This will hide the objects from sight, but the object's collider will still be available for the Physics Raycaster generated by the Teleporter script.
  2. Save the project and scene:
Figure 7.17: TeleportArea GameObjects are added to provide access to various parts of the scene
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.42.168