Audio: SCR_SoundManagerEntity – Arma Reforger
From Bohemia Interactive Community
SCR_SoundManagerEntity is a manager created to play simple one-shot sounds without the need for a SoundComponent to exist on a given entity.
- SCR_SoundManagerEntity is a core entity present in every world.
- If functions in SCR_SoundManagerEntity are enough for a given sound, prioritise it before adding SoundComponent on the entity.
- If the entity already has SoundComponent because of some other sound, do not use SCR_SoundManagerEntity.
- Signals for a given sound can be set only before the sound playback and cannot be updated during the sound playback.
Signals
- By default, the following Variables are used:
- GCurrVehicleCoverage
- GIsThirdPersonCam
- GInterior
- the Distance signal can be enabled using the flags in SCR_AudioSourceConfiguration
- any additional feature-specific signals can be added using the SCR_AudioSource API if needed.
SCR_AudioSourceDefinition
- Class used for setting sound parameters
- This class is used in SCR_SoundDataComponent, or can be used in any feature in script if needed.
- Sound Project (resource) - acp that contains m_sSoundEventName
- Sound Event Name (string) - Sound event name
- Static (flag) - If false, sound will follow the entity's position
SCR_SoundDataComponent
SCR_SoundDataComponent is the best way to configure multiple sounds
It contains an SCR_AudioSourceDefinition array for sounds configuration and SCR_SoundManagerEntity contains methods that can work with this component directly.
Usage
SCR_SoundManagerEntity Scripting
Sound is defined using SCR_AudioSourceConfiguration. You need it to play the sound. Two methods:
- use SCR_SoundDataComponent, which contains the SCR_AudioSourceConfiguration array and is meant to be used when multiple scripts need to play sound on a given entity.
- define SCR_AudioSourceConfiguration directly in a class. Useful when better control over SCR_AudioSourceConfiguration is needed or when there is only a couple of events to be played on the entity
SCR_SoundDataComponent Workflow
Store the string event name in script, then two methods:
- create and play sound using cCreateAndPlayAudioSource(IEntity owner, string eventName)
- alternatively create SCR_AudioSource using cCreateAudioSource(IEntity owner, string eventName) - checks if the sound is in the audible range and play SCR_AudioSource using cPlayAudioSource(SCR_AudioSource audioSource) - sets occlusion signals, distance signal, triggers the sound, and adds SCR_AudioSource to the pool.
SCR_AudioSourceConfiguration Workflow
Validate a SCR_AudioSourceConfiguration instance, then two methods:
- create and play sound using cCreateAndPlayAudioSource(IEntity owner, SCR_AudioSourceConfiguration audioSourceConfiguration)
- alternatively Create a SCR_AudioSource using cCreateAudioSource(IEntity owner, SCR_AudioSourceConfiguration audioSourceConfiguration) and play SCR_AudioSource using cPlayAudioSource(SCR_AudioSource audioSource)