Set the maximum and minimum distance audible for 3d sound effects||doc135613

September 20, 2022


 TdAudioEngine:set3DMinMaxDistance(nSoundId, minDistance, maxDistance)


Set the minimum and farthest distance that the sound effect corresponding to the sound effect ID can be heard in the game scene.


To set the maximum and minimum distance that the sound effect can be heard, you must first obtain the id number of the sound effect to be set. So this function should be matched with the playback function of the sound effectplay3dSoundorplay2dSoundto use.


Variable name type Description
nSoundId int sound effectId
minDistance float Minimum distance value
maxDistance float Maximum distance value

Code Samples

local TdAudioEngine = TdAudioEngine.Instance()
local soundID = TdAudioEngine:play3dSound("asset/Audio/Sound/click.mp3",{x = 0,y = 3,z = 0} ,true)