-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoundManager.cs
46 lines (35 loc) · 1023 Bytes
/
SoundManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using UnityEngine;
using System.Collections;
public class SoundManager : MonoBehaviour {
public AudioClip startup;
public AudioClip onidle1;
CarController carController;
AudioSource _audio;
public float timer_start;
private bool bo=true;
void Start () {
carController = gameObject.GetComponent<CarController>();
_audio = GetComponent<AudioSource>();
_audio.clip = startup;
_audio.pitch = 0.5f;
_audio.Play();
timer_start = startup.length;
}
void Update () {
if (bo)
{
timer_start -= Time.deltaTime;
}
if(timer_start <= 0)
{
if (bo) {
_audio.clip = onidle1;
_audio.loop = true;
_audio.Play();
bo = false;
}
float [] b = carController.Getrmp_float();
_audio.pitch = Mathf.Lerp(0.5f, 3, Mathf.Abs(b[3]+b[2]+b[1]+b[0])/1600);
}
}
}