エンジンクラス
SoundService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
プロパティ
方法
OpenAttenuationCurveEditor(selectedCurveObjects: Instances):() |
OpenDirectionalCurveEditor(selectedCurveObjects: Instances):() |
PlayLocalSound(sound: Instance):() |
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
endAPIリファレンス
プロパティ
方法
OpenAttenuationCurveEditor
SoundService:OpenAttenuationCurveEditor(selectedCurveObjects:Instances):()
パラメータ
selectedCurveObjects:Instances |
戻り値
()
OpenDirectionalCurveEditor
SoundService:OpenDirectionalCurveEditor(selectedCurveObjects:Instances):()
パラメータ
selectedCurveObjects:Instances |
戻り値
()
SetListener
パラメータ
戻り値
()