Skip to content

Haptics Controller

caxawu edited this page Aug 16, 2020 · 2 revisions

Haptics Controller

The haptics controller is for triggering controller haptics. It leverages OVR's controller haptics, but includes a parameter for haptic duration.

Setting up the haptics controller

  1. Drag in the HapcticsController prefab located in Assets->Prefabs->PlayerInteraction->HapticsController. This prefab is just an empty gameobject with the HapticsController script attached.
  2. In the script where you want to use haptics, create an instance of the haptics controller:
    _hapticsController = HapticsController.Instance;
    if (_hapticsController == null) throw new System.Exception("Must have a haptics controller in the scene");
    

Using the haptics controller

In your script, call:

_hapticsController.Haptics(float frequency, float amplitude, float duration, OVRInput.Controller controller);

Frequency: Refers to how frequent the vibration is (any value between 0 and 1 inclusive): this value will most likely not need to be changed

Amplitude: Refers to the strength of the vibration (any value between 0 and 1 inclusive)

Duration: Refers to how long the haptic feedback lasts (any value between 0 and 1 inclusive)

Controller: Refers to which controller the haptic feedback happens on

Example use:

_hapticsController.Haptics(1, 0.25f, 0.1f, OVRInput.Controller.RTouch);