Audio parameter
It is possible to pass in an audio asset to an actor as a parameter in the editor. This makes it possible to easily change the sound that an actor plays from the editor.
The code below illustrates how to define an audio parameter.
First define the parameter. Read more about parameters in Actor parameters
Inject the View controller to access the global audio listener.
Create the instance of a new sound instance to be able to play the audio clip.
Set the sound buffer using the value of the audio parameter in the
onInit
function. At this point the parameters are set. Read more about actors lifecycle functions in Actor lifecycleFinally, we define a function that can be called on the actor to play the sound which could be called whenever the sound should play.
Last updated