Audio & SFX
Music and sound effects are a key piece to any enjoyable game. The Audio class allows you to create and control playback of both ambient and spatial music and sound effects seamlessly within your game.
Playing Ambient Audio
Audio supports a number of features, but let's start with the simplest. Let's say we want to just play some nice ambient music for all of our players. We can do that like so:
Playing Spatial Audio
Oftentimes in games we need to play spatial audio that originates at some point in 3D space of the game, either from a specific coordinate or an entity. In this example, let's play some audio that constantly originates from each player and starts playing when a player joins the game.
Controlling Playback & Effects
Most audio playback settings and effects can be controlled while Audio is already playing. Effects will automatically be interpolated by the client for smooth transitions between effects. This means you can do interesting things like adjust playback speed, distortion, detune, volume, and more while audio plays.
Here's an example of how we can continuously speed up our audio playback of our game music over time.
Diving Deeper
The Audio class supports a wide variety of features and control through various exposed properties and methods. If you'd like to learn more, we recommend digging into the Audio API Reference that can be found here.
If there are features that we don't currently support for Audio that you'd like to see added to the HYTOPIA SDK, you can submit a feature request here.
Next Steps
Last updated