Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "ambientsound"
From Quake Wiki
m (→Other Details:: linked to Engine Limits page) |
|||
Line 1: | Line 1: | ||
− | + | ''void'' '''ambientsound'''(''vector'' pos, ''string'' soundPath, ''float'' volume, ''float'' attenuation) | |
− | + | ||
+ | == Usage == | ||
+ | Starts playing a sound with no connection to any entity. A sound must be precached during map load in order to be considered valid. Once an ambient sound starts playing it cannot be stopped. | ||
+ | |||
+ | Unlike standard sounds, ambient sounds must loop in order to be considered valid (sound markers need to be present in the file). | ||
− | |||
====Parameters:==== | ====Parameters:==== | ||
− | : | + | *''pos'' |
− | : | + | :The origin of the sound. |
− | : | + | *''soundPath'' |
− | :<code> | + | :The path of the sound file. Supports WAV (.wav) files. |
− | + | *''volume'' | |
− | : | + | :Can be a value from 0 to 1. |
− | + | *''attenuation'' | |
− | + | :Determines the linear falloff of the sound over distance. A value of 0 (<code>ATTN_NONE</code>) will have no fall off. The larger the value, the greater the falloff. Default values: | |
+ | :*<code>ATTN_NONE</code> | ||
+ | :*<code>ATTN_NORM</code> | ||
+ | :*<code>ATTN_IDLE</code> | ||
+ | :*<code>ATTN_STATIC</code> | ||
+ | == Example == | ||
+ | // This entity plays an ambient sound when it initializes | ||
+ | void ambient_ocean() | ||
+ | { | ||
+ | precache_sound("ambience/ocean.wav"); | ||
+ | ambientsound(self.origin, "ambience/ocean.wav", 1, ATTN_STATIC); | ||
+ | |||
+ | remove(self); | ||
+ | } | ||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Latest revision as of 18:02, 1 August 2023
void ambientsound(vector pos, string soundPath, float volume, float attenuation)
Usage[edit]
Starts playing a sound with no connection to any entity. A sound must be precached during map load in order to be considered valid. Once an ambient sound starts playing it cannot be stopped.
Unlike standard sounds, ambient sounds must loop in order to be considered valid (sound markers need to be present in the file).
Parameters:[edit]
- pos
- The origin of the sound.
- soundPath
- The path of the sound file. Supports WAV (.wav) files.
- volume
- Can be a value from 0 to 1.
- attenuation
- Determines the linear falloff of the sound over distance. A value of 0 (
ATTN_NONE
) will have no fall off. The larger the value, the greater the falloff. Default values:ATTN_NONE
ATTN_NORM
ATTN_IDLE
ATTN_STATIC
Example[edit]
// This entity plays an ambient sound when it initializes void ambient_ocean() { precache_sound("ambience/ocean.wav"); ambientsound(self.origin, "ambience/ocean.wav", 1, ATTN_STATIC); remove(self); }