IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
SoundBowClick.cs
1 //======= Copyright (c) Valve Corporation, All rights reserved. ===============
2 //
3 // Purpose: Sounds for the bow pulling back
4 //
5 //=============================================================================
6 
7 using UnityEngine;
8 using System.Collections;
9 
10 namespace Valve.VR.InteractionSystem
11 {
12  //-------------------------------------------------------------------------
13  public class SoundBowClick : MonoBehaviour
14  {
15  public AudioClip bowClick;
16  public AnimationCurve pitchTensionCurve;
17  public float minPitch;
18  public float maxPitch;
19 
20  AudioSource thisAudioSource;
21 
22  //-------------------------------------------------
23  void Awake()
24  {
25  thisAudioSource = GetComponent<AudioSource>();
26  }
27 
28 
29  //-------------------------------------------------
30  public void PlayBowTensionClicks( float normalizedTension )
31  {
32  // Tension is a float between 0 and 1. 1 being max tension and 0 being no tension
33  float y = pitchTensionCurve.Evaluate( normalizedTension );
34 
35  thisAudioSource.pitch = ( ( maxPitch - minPitch ) * y ) + minPitch;
36  thisAudioSource.PlayOneShot( bowClick );
37  }
38  }
39 }