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); }
/// <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); }