Skip to main content

Sounds

Sounds are a great way to add a little extra immersion to your game. This page lists of the sound functions available to you in Easel.

Sound effects​

The Hear or Sing functions can be used to play a sound effect in game.

  • Hear is the simplest way to play a sound. It will always play the sound to completion. Use it for sounds that are triggered by events in your game, like a gunshot, an explosion or the "ding" when collecting a coin.
  • Sing will only continue to play a sound as long as its entity continues to exist, or until it is deleted. It is best used for sounds where the entity is actively making the sound, like a spaceship engine, a waterfall or the woosh sound of a fireball. When the spaceship, waterfall or fireball is despawned, the sound stops playing.

Positional audio​

Sounds are played using positional audio, which means a player will be able to hear if a sound is coming from their left or right, and how far away it is.

  • The Sing and Hear functions take a body parameter that determines the body where the sound is coming from.
  • The Ears function determines the body that should act as the listener is in the game world. In most cases, you should set this to the character that the player is controlling.

Music​

The Music function can be used to play music in game. Only one music track can be played at a time - at any given moment, the one with the highest priority will be the one that is heard.

Playback rate​

Both Sing and Hear support a playbackRate parameter, which can be used to speed up or slow down the sound, changing its pitch in the process. If you have a repetitive sound like the "ding" when collecting a coin, you can make it more interesting by shifting the pitch up or down slightly each time it is played.

The Music function also has a playbackRate parameter that can be used to speed up or slow down the music, but by default it does not shift the pitch unless you set pitchShift=true. This can be useful for creating tension in a boss fight, where the music speeds up as the boss gets closer to defeat.

Synthesized Sounds​

Easel comes with its own built-in sound sythesizer that you can use to create your own sound effects. Simply create your sounds as .esfx files, and then use them like normal using a function call like Sing(@fireball-woosh.esfx) or Hear(@explosion.esfx). See ESFX to learn more about the esfx format and how to use it.

Supported Formats​

It is best to stick with formats that most computers can play:

  • mp3 or ogg are the most widely supported formats for sound effects and music.
  • wav is also supported, but it is a much larger file format and can take longer to load for your players.
  • The esfx format is Easel's custom sound format that lets you synthesize sounds with code. It can only be used for sound effects, not music. See ESFX to learn more.

Network Considerations​

Sometimes, due to rollback netcode, a client may only be notified that it needs to start playing a sound effect after the sound should have started. See Slippage to learn more about how this situation is handled in Easel.

See Also​

See the Audio Reference for a complete list of audio functions and parameters.