Set Volume to ()%
set volume to ()%
Category Sound
Type Stack
Introduced in 1.2

The Set Volume to ()% block is a Sound block and a stack block. The block sets its Sprite's volume to the specified amount. It only affects the sprite (or the stage) that the block is in.

Example Uses

As the block sets the volume of a sprite or the stage, it is used when the volume needs to be set to a specified amount, rather than increasing or decreasing.

Some common uses for the Set Volume to () % block:

  • Volume controls
set volume to (volume slider)%
  • Changing sound effect volume (the further away the noise-maker is, the quieter the sound effect should sound)
set volume to ((100) - ((distance to (noise v)) / (2)))%
  • Songs made with the Sound blocks that have loud and quiet parts
set volume to (100)%
play note (60) for (0.5) beats
play note (65) for (0.4) beats
set volume to (75)%
play note (48) for (1) beats

Limitations

If a user attempts input a number smaller than 0, the volume is set to 0%. Conversely, if a user attempts to input a number larger than 100, the volume is set to 100%. Additionally, inputting a number with more than 6 decimal digits will cause the volume to be rounded to the nearest number with 6 decimal digits.

Workaround

Main article: List of Block Workarounds

This block can be replicated by the following code:

change volume by ((vol) - (volume))

See Also