Author Topic: Precipitation data playing a looping sound?  (Read 919 times)

I'm trying to get the 'HeavyRain' and 'MistyRain' precipitation data to play the rain.wav sound, but it doesn't seem to work, i don't know if it's possible or not to have a sound play for Precipitation data, but i'd like some help with this

Code: [Select]
//-----------------------------------------------------------------------------

datablock AudioProfile(HeavyRainSound)
{
   filename    = "./rain.wav";
   description = AudioLooping2D;
   preload = true;
};

datablock PrecipitationData(HeavyRain)
{
   soundProfile = "HeavyRainSound";
   dropTexture = "./rain";
   splashTexture = "./water_splash";
   dropSize = 0.75;
   splashSize = 0.2;
   useTrueBillboards = false;
   splashMS = 250;
};

datablock PrecipitationData(MistyRain)
{
   soundProfile = "HeavyRainSound";
   dropTexture = "./mist";
   splashTexture = "./mist2";
   dropSize = 10;
   splashSize = 0.1;
   useTrueBillboards = false;
   splashMS = 250;
};

 //-----------------------------------------------------------------------------

Also, my apologizes to Space Guy for bugging him first :P


Roughly:
Code: [Select]
if(!isObject(rainSound))
datablock audioProfile(rainSound) {
filename = "./rain.wav";
description = AudioLooping2D;
preload = true;
};
if(!isObject(heavyRain))
datablock precipitationData(heavyRain) {
soundProfile = "rainSound";
dropTexture = "./rain";
splashTexture = "./water_splash";
dropSize = 0.75;
splashSize = 0.2;
useTrueBillboards = false;
splashMS = 250;
};
if(!isObject(mistyRain))
datablock precipitationData(mistyRain) {
soundProfile = "rainSound";
dropTexture = "./mist";
splashTexture = "./mist2";
dropSize = 10;
splashSize = 0.1;
useTrueBillboards = false;
splashMS = 250;
};
if(!isPackage(precipitationSound)) {
package precipitationSound {
function gameConnection::onClientEnterGame(%this) {
parent::onClientEnterGame(%this);
if(isObject(heavyRain) || isObject(mistyRain) && !%this.isPlayingRain) {
%this.play2d(rainSound);
%this.isPlayingRain = true;
}
}
function heavyRain::onAdd(%this) {
parent::onAdd(%this);
for(%i = 0; %i < clientGroup.getCount(); %i++) {
%obj = clientGroup.getObject(%i);
if(!%obj.isPlayingRain) {
clientGroup.getObject(%i).play2d(rainSound);
%this.isPlayingRain = true;
}
}
}
function mistyRain::onAdd(%this) {
parent::onAdd(%this);
for(%i = 0; %i < clientGroup.getCount(); %i++) {
%obj = clientGroup.getObject(%i);
if(!%obj.isPlayingRain) {
clientGroup.getObject(%i).play2d(rainSound);
%this.isPlayingRain = true;
}
}
}
};
activatePackage(precipitationSound);
}

However that is bad code because I don't know how to stop the rain sound.

You definitely shouldn't be doing a play2d on all the clients - what about people who join the server?

You should be using an AudioEmitter object instead, using a 2d audio profile.

You definitely shouldn't be doing a play2d on all the clients
Why not?

what about people who join the server?
Code: [Select]
-snip-
function gameConnection::onClientEnterGame(%this) {
-snip-

You should be using an AudioEmitter object instead, using a 2d audio profile.
But then when you approached another player, wouldn't your rain sound would get louder? Also, how would I make sure that audioEmitter follows the player without spamming schedules to recreate it closer every so often. Or am I confusing the functionality 2d and 3d emitters.

Instead of telling me how mine is bad, why don't you show me how you would do it?

He means a AudioEmitter spawn at the location of the precipitation and having a radius the size of the precipitation, not spawned on clients.

A 2d audio profile applied to an AudioEmitter plays across the entire radius at the same volume, so you only need to spawn one with a large max distance. It wouldn't have taken you long to research this.

Instead of telling me how mine is bad, why don't you show me how you would do it?
I made the mistake of assuming you knew what an AudioEmitter was, or what 2d Audio is. Oops!
« Last Edit: December 22, 2009, 06:57:40 AM by Ephialtes »