SoundEntity¶
SoundEntity, created with YaSoundAPI, allows for playing the configured audio clips.
The audio playback process begins by determining whether an audio clip with the given name exists in the current entity's Playable.
This audio clip will be played if it exists.
If not, the API will then search the Playables of global configurations for an audio clip with the same name and play that audio clip instead.Functions¶
YaSoundHandle PlaySound(string soundName, [boolean isLoop], [number delayTime])¶
ReturnsIf the sound effect does not exist,returns invalid sound handle(YaSoundHandle.IsValid() = false).
Plays 2D sound with no attenuation over distance.
soundNameThe name of the sound you want to playisLoopDetermines whether to loop the audio clip. True if the clip plays in a loopdelayTimeThe delay time in seconds before the audio clip starts playing
YaSoundHandle Play3DSound(string soundName, float3 position, quaternion rotation, [boolean isLoop], [number delayTime])¶
ReturnsIf the sound effect does not exist,returns invalid sound handle(YaSoundHandle.IsValid() = false).
Plays 3D sound at a specific position.
soundNameThe name of the audio clip to playpositionThe position of the audio clip in world spacerotationThe rotation of the audio clip in world space as a quaternionisLoopDetermines whether to loop the audio clip. True if the clip plays in a loopdelayTimeThe delay time in seconds before the audio clip starts playing
YaSoundHandle Play3DSound(string soundName, float3 position, [float3 eulerAngle], [boolean isLoop], [number delayTime])¶
ReturnsIf the sound effect does not exist,returns invalid sound handle(YaSoundHandle.IsValid() = false).
Plays 3D sound at a specific position.
soundNameThe name of the audio clip to playpositionThe position of the audio clip in world spaceeulerAngleThe rotation of the audio clip in world space as Euler angles in degreesisLoopDetermines whether to loop the audio clip. True if the clip plays in a loopdelayTimeThe delay time in seconds before the audio clip starts playing
YaSoundHandle Play3DSound(string soundName, YaEntity followTarget, [number bonePoint], [boolean isLoop], [number delayTime])¶
ReturnsIf the sound effect does not exist,returns invalid sound handle(YaSoundHandle.IsValid() = false).
Plays 3D sound when following a target entity.
soundNameThe name of the audio clip to playfollowTargetThe target entity to followbonePointDetermines the method of following the target. The default value 0 indicates that the root position of the target entity will be followed. If the target is an avatar, value 1, 2, or 4 means to follow the left hand, the right hand, or the top of the head respectively.isLoopDetermines whether to loop the audio clip. True if the clip plays in a loopdelayTimeThe delay time in seconds before the audio clip starts playing
YaSoundHandle PlayBGM(string soundName, [boolean isLoop], [number delayTime])¶
ReturnsIf the sound effect does not exist,returns invalid sound handle(YaSoundHandle.IsValid() = false).
Plays an audio clip as background music. To change the background music, add a new audio clip.
soundNameThe name of the audio clip to playisLoopDetermines whether to loop the audio clip. True if the clip plays in a loopdelayTimeThe delay time in seconds before the audio clip starts playing