Apprendre
Classe de moteur
SoundService
Création impossible
Service

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.


Échantillons de code
Système de réverbération dynamique
local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local SoundService = game:GetService("SoundService")
local localPlayer = Players.LocalPlayer
local reverbTags = {
["reverb_Cave"] = Enum.ReverbType.Cave,
}
-- collecter les parties et les regrouper par tag
local parts = {}
for reverbTag, reverbType in pairs(reverbTags) do
for _, part in pairs(CollectionService:GetTagged(reverbTag)) do
parts[part] = reverbType
end
end
-- fonction pour vérifier si une position est à l'intérieur des limites d'une partie
local function positionInPart(part, position)
local extents = part.Size / 2
local offset = part.CFrame:PointToObjectSpace(position)
return offset.x < extents.x and offset.y < extents.y and offset.z < extents.z
end
local reverbType = SoundService.AmbientReverb
while true do
task.wait()
if not localPlayer then
return
end
local character = localPlayer.Character
-- par défaut, pas de réverbération
local newReverbType = Enum.ReverbType.NoReverb
if character and character.PrimaryPart then
local position = character.PrimaryPart.Position
-- parcourir toutes les parties indexées
for part, type in pairs(parts) do
-- voir si le personnage est à l'intérieur
if positionInPart(part, position) then
-- si oui, choisir ce type de réverbération
newReverbType = type
break
end
end
end
-- définir le type de réverbération s'il a changé
if newReverbType ~= reverbType then
SoundService.AmbientReverb = newReverbType
reverbType = newReverbType
end
end

Référence API
Propriétés
AcousticSimulationEnabled
Lecture parallèle
Capacités : Audio
SoundService.AcousticSimulationEnabled:boolean

AmbientReverb
Lecture parallèle
Capacités : Audio
SoundService.AmbientReverb:Enum.ReverbType

CharacterSoundsUseNewApi
Sécurité des plugins
Lecture parallèle
Capacités : Audio
SoundService.CharacterSoundsUseNewApi:Enum.RolloutState

DefaultListenerLocation
Sécurité des plugins
Lecture parallèle
Capacités : Audio
SoundService.DefaultListenerLocation:Enum.ListenerLocation

DistanceFactor
Lecture parallèle
Capacités : Audio
SoundService.DistanceFactor:number

DopplerScale
Lecture parallèle
Capacités : Audio
SoundService.DopplerScale:number

ListenerCFrame
Lecture parallèle
Capacités : Audio
SoundService.ListenerCFrame:CFrame

ListenerObject
Lecture parallèle
Capacités : Audio
SoundService.ListenerObject:Instance

ListenerType
Lecture parallèle
Capacités : Audio
SoundService.ListenerType:Enum.ListenerType

RespectFilteringEnabled
Lecture parallèle
Capacités : Audio
SoundService.RespectFilteringEnabled:boolean

RolloffScale
Lecture parallèle
Capacités : Audio
SoundService.RolloffScale:number

VolumetricAudio
Non scriptable
Lecture parallèle
Capacités : Audio
SoundService.VolumetricAudio:Enum.VolumetricAudio

Méthodes
GetListener
Capacités : Audio
SoundService:GetListener():Tuple
Retours

GetMixerTime
Capacités : Audio
SoundService:GetMixerTime():number
Retours

OpenAttenuationCurveEditor
Sécurité des plugins
Capacités : Audio
SoundService:OpenAttenuationCurveEditor(selectedCurveObjects:Instances):()
Paramètres
selectedCurveObjects:Instances
Retours
()

OpenDirectionalCurveEditor
Sécurité des plugins
Capacités : Audio
SoundService:OpenDirectionalCurveEditor(selectedCurveObjects:Instances):()
Paramètres
selectedCurveObjects:Instances
Retours
()

PlayLocalSound
Capacités : Audio
SoundService:PlayLocalSound(sound:Instance):()
Paramètres
sound:Instance
Retours
()

SetListener
Capacités : Audio
SoundService:SetListener(
listenerType:Enum.ListenerType, listener:Tuple
):()
Paramètres
listenerType:Enum.ListenerType
listener:Tuple
Retours
()

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.