Networked Sound is a nanos world package allowing to spawn and control Sound entities from serverside with full client sync
- Spawn and control sounds from the server
- Exact same API as the native clientside Sound class
- Automatically queries duration from clients and caches it
- Late-joining players hear sounds at their current playback position
- Sounds replicate only to players in the same dimension
- Attach sounds to entities
- Fully documented with LuaLS annotations
- Download the package
- Place it in your server's
Packages/directory - Add
networked-soundto your server configuration
local my_sound = NetworkedSound(
Vector(-510, 145, 63), -- Location (if a 3D sound)
"nanos-world::A_VR_Confirm", -- Asset Path
false, -- Is 2D Sound
true, -- Auto Destroy (if to destroy after finished playing)
SoundType.SFX,
1, -- Volume
1 -- Pitch
)Manually cache sound durations to prevent querying clients:
-- Cache durations at server startup
NetworkedSound.CacheDuration("package://my-package/Client/Sounds/sfx1.mp3", 1.2)
NetworkedSound.CacheDuration("package://my-package/Client/Sounds/sfx2.mp3", 2.5)
NetworkedSound.CacheDuration("package://my-package/Client/Sounds/sfx3.mp3", 0.4)