Skip to content

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.
  • soundName The name of the sound you want to play
  • isLoop Determines whether to loop the audio clip. True if the clip plays in a loop
  • delayTime The 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.
  • soundName The name of the audio clip to play
  • position The position of the audio clip in world space
  • rotation The rotation of the audio clip in world space as a quaternion
  • isLoop Determines whether to loop the audio clip. True if the clip plays in a loop
  • delayTime The 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.
  • soundName The name of the audio clip to play
  • position The position of the audio clip in world space
  • eulerAngle The rotation of the audio clip in world space as Euler angles in degrees
  • isLoop Determines whether to loop the audio clip. True if the clip plays in a loop
  • delayTime The 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.
  • soundName The name of the audio clip to play
  • followTarget The target entity to follow
  • bonePoint Determines 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.
  • isLoop Determines whether to loop the audio clip. True if the clip plays in a loop
  • delayTime The 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.
  • soundName The name of the audio clip to play
  • isLoop Determines whether to loop the audio clip. True if the clip plays in a loop
  • delayTime The delay time in seconds before the audio clip starts playing