Controlling an interactive Theme
Themes have the primary API calls Load()
, Start()
, and Stop()
. To control themes interactively, the majority of functionality can be achieved using the SetControl function. While everything can be controlled using this function, it is dependent on how the theme has been created and set up.
Theme.SetControl
Below is an example of how you could set a parameter called progress
based on the distance between the Player and the Boss. This could potentially increase the tempo and density of the music, transitioning from a happy harmony to something more dissonant and ominous.
public class SetControlByDistance : MonoBehaviour
{
public Transform Player;
public Transform Boss;
public string ControlName = "progress"
void Update()
{
var distance = Vector3.Distance(Player.position, Boss.position);
var normalizedValue = Mathf.InverseLerp(300, 0, distance);
Reactional.Playback.Theme.SetControl(ControlName, normalizedValue);
}
}
Theme.TriggerStinger
While stingers can be scheduled to play at certain positions on a parameter using SetControl
, a more direct method is to call them directly. The code below will randomly play a stinger from the “ActionStinger” category, provided that one exists in the project.
Reactional.Playback.Theme.TriggerStinger("ActionStinger");
Theme.TriggerPart
Parts are musical sections of a Theme set up by the composer Use TriggerPart() to transition between the musical Parts.
Reactional.Playback.Theme.TriggerPart("MyPart");