Sound Component
- A base class for all
SoundComponent
s - Inherits from VehicleComponent, therefore can be turned on or off, enabled or disabled or have LOD set.
Base Volume and Pitch
- All
SoundComponent
s haveBase Volume
andBase Pitch
fields. These, among with any component-specific sound fields, influence the final volume of anAudioSource
.
Clips
- Each
SoundComponent
has a list ofAudioClip
s. - If more than one
AudioClip
is assigned a randomAudioClip
will be played each time. Note thatSoundComponent
s which play looped sounds - such asEngineRunningComponent
- will only use the firstAudioClip
. - Changing
AudioClip
s at runtime will not automatically change the current playing clip.
Scripting
- Get the first
AudioClip
in theClips
list:
soundComponent.Clip
- Get i-th
AudioClip
in theClips
list:
soundComponent.Clips[i]
- Get the first
AudioSource
in theSources
list:
soundComponent.Source
- Get i-th
AudioSource
in theSources
list:
soundComponent.Sources[i]
- Enable / disable
SoundComponent
:
soundComponent.Enable(); soundComponent.Disable();
- To get/set volume and pitch use
GetVolume
,SetVolume
,GetPitch
andSetPitch
instead of getting and setting the values directly fromAudioSource
. This ensures that the master settings are applied to the values.