Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "sound"

From Quake Wiki

Line 7: Line 7:
 
:<code>sample</code> - The path to the sound file.  Unlike models, sounds have /sound/ already present, so do not include that directory in the pathname.
 
:<code>sample</code> - The path to the sound file.  Unlike models, sounds have /sound/ already present, so do not include that directory in the pathname.
 
:<code>volume</code> - A value between 0.0 and 1.0 that controls the volume of the sound.  0.0 is silent, 1.0 is full volume.
 
:<code>volume</code> - A value between 0.0 and 1.0 that controls the volume of the sound.  0.0 is silent, 1.0 is full volume.
:<code>attenuation</code> - A value greater than or equal to 0 and less than 4 that controls how fast the sound's volume attenuated from distance.  0 can be heard everywhere in the level and 3.999 has a radius of about 250 units.
+
:<code>attenuation</code> - A value greater than or equal to 0 and less than 4 that controls how fast the sound's volume attenuated from distance.  0 can be heard everywhere in the level, 1 can be heard up to 1000 units and 3.999 has a radius of about 250 units.
 
====Returns:====
 
====Returns:====
 
:void
 
:void
 +
====Other Details:====
 +
Sounds started outside the hearing range of the player will not be registered by the engine, so if the player later moves in to hearing range, the sound will not be heard.
 +
Sounds that are looped will continue playing, but if the player moves out of hearing range, the engine will eventually stop playing it and when the player moves back into hearing range, it will no longer be there.
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Revision as of 04:25, 27 March 2013

Syntax:

void sound(entity e, float channel, string sample, float volume, float attenuation)

This function is used for playing a sound.

Parameters:

channel - The channel to play the sound on. A sound played on the same channel as another will override the previous one. Use integer values only.
sample - The path to the sound file. Unlike models, sounds have /sound/ already present, so do not include that directory in the pathname.
volume - A value between 0.0 and 1.0 that controls the volume of the sound. 0.0 is silent, 1.0 is full volume.
attenuation - A value greater than or equal to 0 and less than 4 that controls how fast the sound's volume attenuated from distance. 0 can be heard everywhere in the level, 1 can be heard up to 1000 units and 3.999 has a radius of about 250 units.

Returns:

void

Other Details:

Sounds started outside the hearing range of the player will not be registered by the engine, so if the player later moves in to hearing range, the sound will not be heard. Sounds that are looped will continue playing, but if the player moves out of hearing range, the engine will eventually stop playing it and when the player moves back into hearing range, it will no longer be there.