Cluster Creator Kit Script Reference
    Preparing search index...

    Interface HapticsHandlePlayer

    The handle to control vibration of the controllers or devices of the player. You can access the handle with PlayerScript.hapticsHandle.

    interface HapticsHandle {
        maxFrequencyHz: number | null;
        minFrequencyHz: number | null;
        isAvailable(): boolean;
        playEffect(effect: HapticsEffect, target: HapticsTarget | null): void;
    }
    Index

    Properties

    maxFrequencyHz: number | null

    Returns the absolute frequency value in Hz when 1 is specified to HapticsEffect.frequency .

    The frequency setting will not be reflected in the actual vibration feedback in the following cases:

    • This API returns null.
    • The device does not support vibration frequency setting.
    minFrequencyHz: number | null

    Returns the absolute frequency value in Hz when 0 is specified to HapticsEffect.frequency .

    The frequency setting will not be reflected in the actual vibration feedback in the following cases:

    • This API returns null.
    • The device does not support vibration frequency setting.

    Methods

    • Gets whether the device's vibration function is available.

      Returns true if the device supports vibration and vibration feedback is not disabled in "Settings".

      In mobile environments, vibration can be enabled or disabled with "Vibration" at "Haptic feedback" in the "Controls" tab of "Settings".

      Returns boolean

    • Plays vibration feedback if vibration is supported by the controller or device of the player.

      In VR environments, the controllers will provide vibration feedback.
      If target is set to "left" or "right", vibration feedback will be played on the corresponding left or right controller.
      If target is an unsupported value or null, vibration feedback will be played on both controllers.

      On mobile devices that support vibration, the device itself will provide vibration feedback.
      target value is ignored.

      If vibration is not available on the device, the call to playEffect() will be ignored.

      Parameters

      • effect: HapticsEffect

        The content of the vibration feedback

      • target: HapticsTarget | null

        A string value indicating the target to vibrate ("left" or "right"), or null for unspecified

      Returns void

      // Plays vibration feedback, by both controllers in VR environment, or by the device itself in mobile environment.
      const effect = new HapticsEffect();
      effect.frequency = 0.1;
      effect.amplitude = 1;
      effect.duration = 0.1;
      _.hapticsHandle.playEffect(effect, null);