เรียนรู้
Engine Class
SoundService
ไม่สามารถสร้าง
บริการ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
วิธีการ
OpenAttenuationCurveEditor(selectedCurveObjects: Instances):()
OpenDirectionalCurveEditor(selectedCurveObjects: Instances):()
SetListener(listenerType: Enum.ListenerType,listener: Tuple):()
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
ระบบรีเวิร์บไดนามิก
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,
}
-- เก็บรวบรวมส่วนและจัดกลุ่มตามแท็ก
local parts = {}
for reverbTag, reverbType in pairs(reverbTags) do
for _, part in pairs(CollectionService:GetTagged(reverbTag)) do
parts[part] = reverbType
end
end
-- ฟังก์ชันเพื่อตรวจสอบว่าตำแหน่งอยู่ในขอบเขตของส่วนหรือไม่
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
-- ตั้งค่าเริ่มต้นเป็นไม่มีรีเวิร์บ
local newReverbType = Enum.ReverbType.NoReverb
if character and character.PrimaryPart then
local position = character.PrimaryPart.Position
-- ผ่านทุกส่วนที่ทำดัชนี
for part, type in pairs(parts) do
-- ดูว่าตัวละครอยู่ในส่วนเหล่านั้นหรือไม่
if positionInPart(part, position) then
-- หากเป็นเช่นนั้น ให้เลือกประเภทรีเวิร์บนั้น
newReverbType = type
break
end
end
end
-- ตั้งค่าประเภทรีเวิร์บหากมีการเปลี่ยนแปลง
if newReverbType ~= reverbType then
SoundService.AmbientReverb = newReverbType
reverbType = newReverbType
end
end

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AcousticSimulationEnabled
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.AcousticSimulationEnabled:boolean

AmbientReverb
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.AmbientReverb:Enum.ReverbType

CharacterSoundsUseNewApi
การรักษาความปลอดภัยของปลั๊กอิน
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.CharacterSoundsUseNewApi:Enum.RolloutState

DefaultListenerLocation
การรักษาความปลอดภัยของปลั๊กอิน
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.DefaultListenerLocation:Enum.ListenerLocation

DistanceFactor
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.DistanceFactor:number

DopplerScale
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.DopplerScale:number

ListenerCFrame
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.ListenerCFrame:CFrame

ListenerObject
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.ListenerObject:Instance

ListenerType
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.ListenerType:Enum.ListenerType

RespectFilteringEnabled
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.RespectFilteringEnabled:boolean

RolloffScale
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.RolloffScale:number

VolumetricAudio
ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน
ความสามารถ: Audio
SoundService.VolumetricAudio:Enum.VolumetricAudio

วิธีการ
GetListener
ความสามารถ: Audio
SoundService:GetListener():Tuple
ส่งค่ากลับ

GetMixerTime
ความสามารถ: Audio
SoundService:GetMixerTime():number
ส่งค่ากลับ

OpenAttenuationCurveEditor
การรักษาความปลอดภัยของปลั๊กอิน
ความสามารถ: Audio
SoundService:OpenAttenuationCurveEditor(selectedCurveObjects:Instances):()
พารามิเตอร์
selectedCurveObjects:Instances
ส่งค่ากลับ
()

OpenDirectionalCurveEditor
การรักษาความปลอดภัยของปลั๊กอิน
ความสามารถ: Audio
SoundService:OpenDirectionalCurveEditor(selectedCurveObjects:Instances):()
พารามิเตอร์
selectedCurveObjects:Instances
ส่งค่ากลับ
()

PlayLocalSound
ความสามารถ: Audio
SoundService:PlayLocalSound(sound:Instance):()
พารามิเตอร์
sound:Instance
ส่งค่ากลับ
()

SetListener
ความสามารถ: Audio
SoundService:SetListener(
listenerType:Enum.ListenerType, listener:Tuple
):()
พารามิเตอร์
listenerType:Enum.ListenerType
listener:Tuple
ส่งค่ากลับ
()

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ