Skip to content

Movement

Jasmine Mai edited this page Aug 26, 2020 · 3 revisions

Currently, the movement does not change with vision switch. Therefore, you must consider what the main movement of the native animal is, then add the relevant movement prefabs to the scene to allow for that movement.

Movement Prefabs

These are prefabs that control a specific type of player movement, like teleport or fly. Each movement prefab has its own script depending on the type of movement (e.g. the Teleport prefab should have the TeleportController.cs script). Currently we have the following movement prefabs:

Usage

Add the movement prefabs you want your scene to support.

Teleport

The Teleport prefab consists of the TeleportController.cs script. On the TeleportController.cs script, you can adjust which layers the raycast can detect, which layers can be teleported to, the teleport distance, and the button to trigger teleportation. You can also adjust the line renderer colors.

Using the Teleport Controller script

The TeleportController script allows users to teleport around a scene. To use it, add an instance of the script to any object in the scene. There is already a Teleport prefab setup in prefabs that you can just drag into your scene. It can be used with the HapticsController prefab to use haptics to indicate what is a valid teleport location.

  • In the Camera Rig parameter, drag your OVRCameraRig. This is the object that will be moved whenever a teleport occurs.
  • In the Ray Origin field, put the object that you wish to be the source of the teleport ray. In virtually all cases, this will be either the RightHandAnchor or LeftHandAnchor under the OVRCameraRig's TrackingSpace.
  • Valid Raycast Layers is the list of layers that the raycast will collide with. The teleport ray will pass through layers not on this list.
  • Valid Teleport Layers is the list of layers that the user is allowed to teleport to. If the ray intersects an object on a layer on this list, it will change to the valid color, indicating the teleport is valid. If the ray intersects an object on a layer not on this list, it will turn to the invalid color.
  • Set Teleport Button to the button that must be pressed (and held) to show the teleport ray. When this button is released while the ray intersects an valid teleport layer, the Camera Rig will be moved to the ray's point of intersection.
  • Set Teleport Range to the maximum range a user can teleport.
  • For the teleport ray to appear visually, it must be represented by a Line Renderer. Pass any Line Renderer to the Line Renderer parameter, which will then be used to render the teleport ray.
  • Set Valid Color to the color you want the teleport ray to become when intersecting a valid surface.
  • Set `Invalid Color to the color you want the teleport ray to become when intersecting an invalid surface.

Line Renderer Settings

Generally, you should reduce the line's width to somewhere around .01'. Also, ensure that Element 0underMaterialsis set toDefault-Line`. (a default Unity material).

Using the Teleport Prefab

The Teleport prefab already has most of the correct settings, and is therefore simpler to use.

  1. Drag an instance of the prefab into the scene.
  2. Make sure to set the Camera Rig and Ray Origin properties properly, as mentioned above.
  3. Additionally, you may want to modify the Valid Raycast Layers, Valid Teleport Layers, and Teleport Range to tailor the Teleport to the scene.

Fly

The Fly prefab consists of the FlightController.cs script. This takes care of moving the headset forward and turning on wind particles and wind sound to simulate flying.

  1. Drag an instance of the prefab into the scene.
  2. Drag in the OVRCamerRig to the Camera Rig slot in the inspector.
  3. Drag in the CenterEyeAnchor of the OVRCameraRig to the Center Eye slot in the inspector.
  4. Adjust the flight speed and how fast you want the headset to fade in and out when you stop and start flying.