er2.playClip3D 71
Play a 3D Audio Clip, coming from a specific location and with a maximum hear distance (.wav).
Notice: In various occasions, such as host change, a phase script might restart, so make use of set and get to check whenever set to be played in loop forever was already initialized to avoid spawning it multiple times.
Return value
Return Type | Description |
---|---|
void | this function doesn't return anything |
Parameters
Parameter | Type | Description |
---|---|---|
1 | string | File name and extension of the clip to play. Currently only .wav files are supported. File must be placed inside a folder called "sounds" inside your mission folder (C://..../yourmission/sounds/) |
2 | vec3 | Origin of the sound |
3 | float | Maximum range where the sound where be heard |
4 | bool | (Optional) Set to true if you want the clip to be played on all clients. False if you want it to be played on the client executing the script only. Default is True |
5 | float | (Optional) Volume multiplier. Default is 1 |
6 | float | (Optional) Max duration of the clip. Default is 0, which represent entire clip duration. Notice: If you set |
7 | bool | (Optional) True if you want the clip to keep playing in loop. Default is false |
Examples
Example 129
-- play a clip called "clip.wav" located inside "<mission folder>/sounds/" at location "0,0,1000" for a radius of 10m, synched online, at default volume, one time
er2.playClip3D("clip.wav", vec3(0,0,0), 10)
Example 130
-- we want to play a clip forever, so first of all let's see if someone (like a previous host) already started playing the clip
-- if we never initialized the variable, the value will be nil
if global.get("loop_clip_played") == nil then
-- play a clip called "clip.wav" located inside "<mission folder>/sounds/" at location "0,0,1000" for a radius of 10m, synched online, at default volume, looped forever
er2.playClip3D("clip.wav", vec3(0,0,1000), 10, true, 1, 0, true)
-- set a global variable to remember that we initialized the audio already
global.set(true, "loop_clip_played")
end