/**************************************************************************** * Copyright 2019 Nreal Techonology Limited. All rights reserved. * * This file is part of NRSDK. * * https://www.nreal.ai/ * *****************************************************************************/ using UnityEngine; namespace NRKernal.NRExamples { /// A simple controller vibration. public class SimpleControllerVibration : MonoBehaviour { /// The vibration time. public float vibrationTime = 0.06f; /// The vibration buttons. public ControllerButton[] vibrationButtons = { ControllerButton.TRIGGER, ControllerButton.APP, ControllerButton.HOME }; /// Updates this object. void Update() { if (vibrationButtons == null || vibrationButtons.Length == 0) return; for (int i = 0; i < vibrationButtons.Length; i++) { if (NRInput.GetButtonDown(ControllerHandEnum.Right, vibrationButtons[i])) NRInput.TriggerHapticVibration(ControllerHandEnum.Right, vibrationTime); if (NRInput.GetButtonDown(ControllerHandEnum.Left, vibrationButtons[i])) NRInput.TriggerHapticVibration(ControllerHandEnum.Left, vibrationTime); } } } }