CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
Controlling the number of Voices for each object in the game
For Cues such as character dialogue or effects, the "Category Cue Limit" is usually set in Atom Craft. It prevents the game from simultaneously playing Cues from a same category more than a specified number of times.
However, in a situation such as playing the same character for both sides in a fighting game, only one player's voice would be played at a time due to the Cue Limit setting.
In that case, it would be better to limit the number of voices per "object in the game". The steps below show how you can do this by using the "sound object" function.

1. Specify Category Cue Limits for Cues
Create a category in AtomCraft, enable the Cue Limit, and then assign the category to the Cues for which you want to limit the number of voices.

adx2u_practice_cuelimit.png

2. Associate the AtomEx player with a sound object
In the script, create a CriWare.CriAtomExSoundObject corresponding to the in-game object and register a dedicated CriWare.CriAtomExPlayer ,
so that the Cue Limit set by AtomCraft will be applied to each sound object separately, and each player will be able to play the Cue at the same time.
In the sample code below, a different CriWare.CriAtomExSoundObject is associated with each CriWare.CriAtomSource specified in the Inspector, and the Category Cue Limit is applied to each player.
public class ExampleScript : MonoBehaviour {
/* Players for each character's voice */
public CriAtomSource[] atomSources;
/* Sound object for each character */
private CriAtomExSoundObject[] soundObjects;
void Start ()
{
int numSources = atomSources.Length;
soundObjects = new CriAtomExSoundObject[numSources];
for (int i = 0; i < numSources; i++) {
/* Create a sound object with the Category Cue Limit scope enabled */
soundObjects[i] = new CriAtomExSoundObject(false, true);
/* Add the player to the sound object */
soundObjects[i].AddPlayer(atomSources[i].player);
}
}
void OnDestroy() {
for (int i = 0; i < soundObjects.Length; i++) {
soundObjects[i].DeleteAllPlayers();
soundObjects[i].Dispose();
}
}
}