コード例 #1
0
        /// <summary>
        /// Coroutine called when calling Trigger Haptic pulse for the ps4
        /// </summary>
        /// <param name="durationMicroSec"></param>
        /// <param name="intensity"></param>
        /// <returns></returns>
        private IEnumerator Vibrate(float durationMicroSec, int intensity = 64)
        {
            //Changes the intensity value depending on the value passed
            //Instead of yielding between times, have a constant stream of vibration
            //Coroutine stops in TriggerHaptic pulse if it's not called
            //Working as intended, but not sure if it's the best way to approach it, different than the vive
            if (durationMicroSec <= 200)
            {
                intensity = 64;
            }
            else if (durationMicroSec <= 400)
            {
                intensity = 128;
            }
            else if (durationMicroSec <= 600)
            {
                intensity = 150;
            }
            else if (durationMicroSec > 600)
            {
                intensity = 255;
            }
            PS4Input.MoveSetVibration(0, whichController, intensity);
            // Debug.Log("Calling vibrate from PS4 move before yield");
            yield return(null);

            PS4Input.MoveSetVibration(0, whichController, 0); //Not sure if this is called
            // yield return new WaitForSeconds(durationInSeconds);
            // PS4Input.MoveSetVibration(0, whichController, 0);
            // Debug.Log("Calling vibrate from PS4 after yield");
        }