Impara
Classe motore
SoundService
Non costruibile
Assistenza

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.


Campioni di codice
Sistema di Riverbero Dinamico
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,
}
-- raccogliere parti e raggrupparle per tag
local parts = {}
for reverbTag, reverbType in pairs(reverbTags) do
for _, part in pairs(CollectionService:GetTagged(reverbTag)) do
parts[part] = reverbType
end
end
-- funzione per controllare se una posizione si trova all'interno delle dimensioni di una parte
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
-- impostazione predefinita senza riverbero
local newReverbType = Enum.ReverbType.NoReverb
if character and character.PrimaryPart then
local position = character.PrimaryPart.Position
-- controlla tutte le parti indicizzate
for part, type in pairs(parts) do
-- verifica se il personaggio è all'interno di esse
if positionInPart(part, position) then
-- se sì, scegli quel tipo di riverbero
newReverbType = type
break
end
end
end
-- imposta il tipo di riverbero se è cambiato
if newReverbType ~= reverbType then
SoundService.AmbientReverb = newReverbType
reverbType = newReverbType
end
end

Riferimento API
Proprietà
AcousticSimulationEnabled
Lettura Parallela
Capacità: Audio
SoundService.AcousticSimulationEnabled:boolean

AmbientReverb
Lettura Parallela
Capacità: Audio
SoundService.AmbientReverb:Enum.ReverbType

CharacterSoundsUseNewApi
Sicurezza Plugin
Lettura Parallela
Capacità: Audio
SoundService.CharacterSoundsUseNewApi:Enum.RolloutState

DefaultListenerLocation
Sicurezza Plugin
Lettura Parallela
Capacità: Audio
SoundService.DefaultListenerLocation:Enum.ListenerLocation

DistanceFactor
Lettura Parallela
Capacità: Audio
SoundService.DistanceFactor:number

DopplerScale
Lettura Parallela
Capacità: Audio
SoundService.DopplerScale:number

ListenerCFrame
Lettura Parallela
Capacità: Audio
SoundService.ListenerCFrame:CFrame

ListenerObject
Lettura Parallela
Capacità: Audio
SoundService.ListenerObject:Instance

ListenerType
Lettura Parallela
Capacità: Audio
SoundService.ListenerType:Enum.ListenerType

RespectFilteringEnabled
Lettura Parallela
Capacità: Audio
SoundService.RespectFilteringEnabled:boolean

RolloffScale
Lettura Parallela
Capacità: Audio
SoundService.RolloffScale:number

VolumetricAudio
Non programmabile
Lettura Parallela
Capacità: Audio
SoundService.VolumetricAudio:Enum.VolumetricAudio

Metodi
GetListener
Capacità: Audio
SoundService:GetListener():Tuple
Restituzioni

GetMixerTime
Capacità: Audio
SoundService:GetMixerTime():number
Restituzioni

OpenAttenuationCurveEditor
Sicurezza Plugin
Capacità: Audio
SoundService:OpenAttenuationCurveEditor(selectedCurveObjects:Instances):()
Parametri
selectedCurveObjects:Instances
Restituzioni
()

OpenDirectionalCurveEditor
Sicurezza Plugin
Capacità: Audio
SoundService:OpenDirectionalCurveEditor(selectedCurveObjects:Instances):()
Parametri
selectedCurveObjects:Instances
Restituzioni
()

PlayLocalSound
Capacità: Audio
SoundService:PlayLocalSound(sound:Instance):()
Parametri
sound:Instance
Restituzioni
()

SetListener
Capacità: Audio
SoundService:SetListener(
listenerType:Enum.ListenerType, listener:Tuple
):()
Parametri
listenerType:Enum.ListenerType
listener:Tuple
Restituzioni
()

© 2026 Roblox Corporation. Roblox, il logo Roblox e Powering Imagination sono tra i nostri marchi registrati e non registrati negli Stati Uniti. e altri paesi.