LogoLogo
  • Get Started
  • Getting Started
    • Initial Setup
    • Create Your First Game
    • API Reference
    • Build Your First World Map
    • Multiplayer Testing
    • Use Templates & Examples
    • Styling & Assets
      • Modeling Guidelines
      • Texturing Guidelines
      • Default Assets
  • Build Faster With AI Tools
  • SDK Guides
    • Assets
    • Audio & SFX
      • Audio Manager
    • Blocks & Chunks
      • Block Types
      • Block Type Registry
      • Chunks
      • Chunk Lattice
    • Camera
    • Chat & Commands
    • Debugging
    • Entities
      • Animations
      • Block Entities
      • Colliders & Hitbox
      • Child Entities
      • Entity Controllers
        • Base Entity Controller
        • Pathfinding Entity Controller
        • DefaultPlayer Entity Controller
        • Simple Entity Controller
      • Entity Manager
      • Model Entities
      • Movement & Pathfinding
      • Player Controlled Entities
    • Events
    • Input & Controls
    • Lighting
      • Ambient Light
      • Light Manager
      • Point Lights
      • Spot Lights
      • Sun Light (Directional)
    • Mobile
    • Persisted Data
    • Players
      • Player Manager
      • Persisted Player Data
    • Plugins
    • Physics
      • Colliders
      • Collision Groups
      • Debugging
      • Gravity
      • Raycasts
      • Rigid Bodies
    • User Interface
      • Overlay UI
      • Scene UIs
      • Scene UI Manager
    • Worlds
      • Map Data Format
  • Helpful Resources
    • HYTOPIA Architecture & Platform Overview
    • Useful Third-Party Tools
Powered by GitBook
On this page
  • Accessing An AudioManager
  • Using An AudioManager
  • Diving Deeper
Export as PDF
  1. SDK Guides
  2. Audio & SFX

Audio Manager

In more complex games, it's common to have many difference pieces of audio playing at the same time. This can become cumbersome to track or manage, especially if you need to do things like perform operations on all types of one specific kind of audio.

Thankfully, we have the AudioManager that exposes ways to quickly retrieve and iterate all Audio playbacks in a world.

Accessing An AudioManager

The AudioManager is used as a singleton and automatically created for a given world instance.

You can access the audio manager for a world like this:

world.audioManager

Using An AudioManager

The AudioManager exposes a number of ways to get different types of Audio for a world. Here's some examples of how to use it.

// Returns an array of all loaded audio instances
// for the world
world.audioManager.getAllAudios(); // You can iterate and manipulate each audio from here with .forEach, etc.

// Returns an array of all loaded audio instances
// attached to the provided entity
world.audioManager.getAllEntityAttachedAudios(someEntity);

// Returns an array of all loaded looped audio instances
// with loop: true
world.audioManager.getAllLoopedAudios();

// Returns an array of all loaded one-shot audio instances
// that have loop: false, or omitted loop
world.audioManager.getAllOneshotAudios();

Diving Deeper

PreviousAudio & SFXNextBlocks & Chunks

Last updated 4 months ago

The AudioManager class is constantly evolving. You can find the latest .

If there are features that we don't currently support for AudioManager that you'd like to see added to the HYTOPIA SDK, you can .

AudioManager API Reference here
submit a feature request here