private HapticHandle CreateImpulseHandle(SideOfHaptic side)
        {
            if (TypeOfImpulse == ImpulseType.None)
            {
                return(null);
            }
            else if (TypeOfImpulse == ImpulseType.Emanation)
            {
                bool mirror  = side == SideOfHaptic.Left;
                var  impulse = ImpulseGenerator.BeginEmanatingEffect(mirror ? StartLocation.Mirror() : StartLocation, depth);

                HapticSequence seq = new HapticSequence();
                seq.LoadFromAsset(HapticSequence);

                impulse.WithEffect(seq).WithAttenuation(attenuationPercentage).WithDuration(Duration);

                return(impulse.Play());
            }
            else if (TypeOfImpulse == ImpulseType.Traversal)
            {
                bool mirror  = side == SideOfHaptic.Left;
                var  impulse = ImpulseGenerator.BeginTraversingImpulse(
                    mirror ? StartLocation.Mirror() : StartLocation,
                    mirror ? EndLocation.Mirror() : EndLocation);

                HapticSequence seq = new HapticSequence();
                seq.LoadFromAsset(HapticSequence);

                impulse.WithEffect(seq).WithAttenuation(attenuationPercentage).WithDuration(Duration);

                return(impulse.Play());
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// Begins an emanation at the nearest flag from the point.
        /// Assigns a strength of 1.0f to the effect. (no attenuation support yet)
        /// </summary>
        /// <param name="point">A point near the player's body</param>
        /// <param name="eff">The effect to use in the emanation.</param>
        /// <param name="effectDuration">How long the impulse's effect is</param>
        /// <param name="impulseDuration">How long the entire impulse takes to visit each step of the depth</param>
        /// <param name="strength">How strong the individual effect is (no support for attenuation yet)</param>
        /// <param name="depth">The depth of the emanating impulse</param>
        /// <param name="maxDistance">Will not return locations further than the max distance.</param>
        public void HitImpulse(Vector3 point, Effect eff = Effect.Pulse, float effectDuration = .2f, float impulseDuration = .5f, float strength = 1.0f, int depth = 1, float maxDistance = 5.0f)
        {
            AreaFlag loc = FindNearestFlag(point, maxDistance);

            if (loc != AreaFlag.None)
            {
                ImpulseGenerator.BeginEmanatingEffect(loc, depth).WithEffect(Effect.Pulse, effectDuration, strength).WithDuration(impulseDuration).Play();
            }
            else
            {
                Debug.LogWarning("Invalid Hit at " + point + "\n");
            }
        }
Example #3
0
        /// <summary>
        /// Begins an emanation at the nearest flag from the point.
        /// Has support for repetitions
        /// </summary>
        /// <param name="point">A point near the player's body</param>
        /// <param name="sequence">The HapticSequence to play on each pad visited.</param>
        /// <param name="impulseDuration">How long the entire impulse takes to visit each step of the depth</param>
        /// <param name="depth">The depth of the emanating impulse</param>
        /// <param name="repeats">Support for repeated impulse</param>
        /// <param name="delayBetweenRepeats">Do we delay between the impulse plays (delay of 0 will play all at once, having no effect)</param>
        /// <param name="maxDistance">Will not return locations further than the max distance.</param>
        public void HitImpulse(Vector3 point, HapticSequence sequence, float impulseDuration = .2f, int depth = 2, int repeats = 0, float delayBetweenRepeats = .15f, float maxDistance = 5.0f)
        {
            AreaFlag loc = FindNearestFlag(point, maxDistance);

            if (loc != AreaFlag.None)
            {
                ImpulseGenerator.Impulse imp = ImpulseGenerator.BeginEmanatingEffect(loc, depth).WithEffect(sequence).WithDuration(impulseDuration);
                if (repeats > 0)
                {
                    StartCoroutine(RepeatedEmanations(imp, delayBetweenRepeats, repeats));
                }
                else
                {
                    imp.Play();
                }
            }
            else
            {
                Debug.LogWarning("Invalid Hit at " + point + "\n");
            }
        }
Example #4
0
 /// <summary>
 /// Calls ImpulseGenerator.BeginTraversingImpulse with the given sequence.
 /// </summary>
 /// <param name="startLocation">The origin of the traversing impulse.</param>
 /// <param name="endLocation">The destination of the traversing impulse.</param>
 /// <param name="sequence">The sequence to use.</param>
 /// <param name="impulseDuration">How long the entire impulse should take</param>
 public void TraversingHit(AreaFlag startLocation, AreaFlag endLocation, HapticSequence sequence, float impulseDuration = .75f)
 {
     ImpulseGenerator.BeginTraversingImpulse(startLocation, endLocation).WithDuration(impulseDuration).Play(sequence);
 }
Example #5
0
 /// <summary>
 /// Calls ImpulseGenerator.BeginEmanatingEffect with the given sequence and depth.
 /// </summary>
 /// <param name="origin">The location to start the emanation.</param>
 /// <param name="sequence">The sequence to use.</param>
 /// <param name="depth">How many steps you want the emanation to take.</param>
 /// <param name="impulseDuration">How long the entire impulse should take</param>
 public void EmanatingHit(AreaFlag origin, HapticSequence sequence, float impulseDuration = .75f, int depth = 2)
 {
     ImpulseGenerator.BeginEmanatingEffect(origin, depth).WithDuration(impulseDuration).Play(sequence);
 }