Audio Source
- 소리를 재생한다. 즉 씬에서 소리의 근원지, 소리를 내는 위치를 결정하는 것이다. 오브젝트 안 컴포넌트로 상속시켜 어떤 종류의 소리(audio clip)을 씬 안에서 play 할 것인지 결정한다.
audio source에서 audio listener까지의 거리에 따른 Volume, Spread, Low-Pass, Reverb Zone, Spatial Blend 을 함수로 설정할 수 있다. Rolloff 모드를 설정하여 직선형, 로그 함수형, 사용자 정의형을 따로 할 수 있다.
audio source 컴포넌트를 찾아 audioSource 변수에 저장하고, clip 프로퍼티에 bulletSound를 대입하는 것으로 audioSource에서 출력할 소리를 지정한다. 이후 audioSource.Play()로 클립를 출력한다.
public AudioClip bulletSound;
private AudioSource audioSource;
audioSource = GetComponent();
audioSource.clip = bulletSound;
audioSource.Play();