AudioEmitter

Hiển Thị Bản Đã Lỗi Thời

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.

AudioEmitter phát luồng âm thanh ra thế giới.Nó cung cấp một đầu nhập duy nhất có thể được kết nối với bởi một hoặc nhiều Wires .Bất kỳ luồng nào được kết nối với một AudioEmitter được phát sóng ra thế giới từ vị trí của cha của người phát.Nếu cha là một Attachment , Camera hoặc PVInstance , vị trí thế giới của cha sẽ được sử dụng.Nếu cha không phải là một trong những lớp này, AudioEmitter là hiệu quả im lặng.

AudioEmitters được nghe bởi AudioListeners để thực hiện không gian hóa 3D.

Mẫu mã

Playing one asset from multiple 3d locations at once

local part1: BasePart = workspace.Speakers.Left
local part2: BasePart = workspace.Speakers.Right
local player: AudioPlayer = workspace.AudioPlayer
local leftEmitter = Instance.new("AudioEmitter")
local rightEmitter = Instance.new("AudioEmitter")
local toLeft = Instance.new("Wire")
local toRight = Instance.new("Wire")
leftEmitter.Parent = part1
rightEmitter.Parent = part2
toLeft.Parent = leftEmitter
toLeft.SourceInstance = player
toLeft.TargetInstance = leftEmitter
toRight.Parent = rightEmitter
toRight.SourceInstance = player
toRight.TargetInstance = rightEmitter
player:Play()

Tóm Tắt

Thuộc Tính

Phương Pháp

Sự Kiện

Thuộc Tính

AngleAttenuation

BinaryString
Bảo Mật Roblox
Đọc Song Song

AudioInteractionGroup

Đọc Song Song

DistanceAttenuation

BinaryString
Bảo Mật Roblox
Đọc Song Song
Đọc Song Song

Phương Pháp

GetAngleAttenuation


Lợi Nhuận

GetAudibilityFor

Tham Số

listener: AudioListener
Giá Trị Mặc Định: ""

Lợi Nhuận

GetConnectedWires

Instances

Tham Số

pin: string
Giá Trị Mặc Định: ""

Lợi Nhuận

Instances

GetDistanceAttenuation


Lợi Nhuận

GetInputPins


Lợi Nhuận

GetInteractingListeners

Instances

Lợi Nhuận

Instances

GetOutputPins


Lợi Nhuận

SetAngleAttenuation

()

Tham Số

curve: Dictionary
Giá Trị Mặc Định: ""

Lợi Nhuận

()

SetDistanceAttenuation

()

Tham Số

curve: Dictionary
Giá Trị Mặc Định: ""

Lợi Nhuận

()

Mẫu mã

Giảm khoảng cách tùy chỉnh

local Players = game:GetService("Players")
local emitterPart = Instance.new("Part")
emitterPart.Anchored = true
emitterPart.Position = Vector3.new(0, 0, 0)
emitterPart.Parent = workspace
local emitter: AudioEmitter = Instance.new("AudioEmitter")
emitter.Parent = emitterPart
local curve = {}
curve[10] = 1 -- Trong khoảng cách 10 đinh tán, người lắng nghe nghe nhà phát này ở âm lượng tối đa
curve[100] = 0.4 -- Ở khoảng cách 100 đinh tán, người lắng nghe nghe phát xạ này ở 40% âm lượng
curve[300] = 0 -- Ở bất kỳ khoảng cách xa hơn 300 đinh tán, người lắng nghe không thể nghe thấy nhà phát này
emitter:SetDistanceAttenuation(curve)
-- Sao chép đồ thị cuộn từ thực hiện cũ của giọng nói
-- Giọng mặc định mà không có API âm thanh mới sử dụng công thức giảm dần từ 7 đến 80 đinh tán
local MIN_DISTANCE = 7
local MAX_DISTANCE = 80
local CURVE_STEP_SIZE = 2
local voiceCurve = {}
for i = MIN_DISTANCE, MAX_DISTANCE, CURVE_STEP_SIZE do
voiceCurve[i] = ((i - MIN_DISTANCE) - (MAX_DISTANCE - MIN_DISTANCE)) ^ 2 / (MAX_DISTANCE - MIN_DISTANCE) ^ 2
end
voiceCurve[MAX_DISTANCE] = 0
local function setVoiceCurve(character)
local voiceEmitter: AudioEmitter = character:WaitForChild("AudioEmitter")
voiceEmitter:SetDistanceAttenuation(voiceCurve)
end
for _, player in Players:GetPlayers() do
if player.Character then
setVoiceCurve(player.Character)
end
player.CharacterAdded:Connect(setVoiceCurve)
end

Sự Kiện

WiringChanged

Tham Số

connected: boolean
pin: string
wire: Wire
instance: Instance