Author Topic: Sound trigger  (Read 1043 times)

Is this correct? Its for a wheeled vehicle

Code: [Select]
datablock AudioProfile(hornSound)
{
   filename    = "./sound/horn.wav";
   description = AudioClosestLooping3d;
   preload = true;
};

function testcar::onTrigger(%data, %obj, %trigger, %state)
{
   // data = datablock
   // obj = object number
   // trigger = 0 for "fire", 1 for "jump", 3 for "thrust"
   // state = 1 for firing, 0 for not firing
   if(%trigger == 0)
   {
%obj.play2d(hornsound);
   }
}

Im terrible at scripting. Txs in advance

Code: [Select]
datablock AudioProfile(hornSound)
{
   filename    = "./sound/horn.wav";
   description = AudioClose3d;
   preload = true;
};

function testcar::onTrigger(%data, %obj, %trigger, %state)
{
   // data = datablock
   // obj = object number
   // trigger = 0 for "fire", 1 for "jump", 3 for "thrust"
   // state = 1 for firing, 0 for not firing
   if(%trigger == 1)
   {
    serverplay3d(hornsound,%obj.getTransform());
   }
}

Try that. When you push Space, the sound plays.

I would suggest using AudioDefault2D instead of AudioClose3D for a sound that's only ever going to play in 2D.

For a vehicle, the horn should play in 3d, near the vehicle - if it could be heard through the whole server with no restriction on how much you push Space, it could get annoying.

dosen't seem to do anything

Lolwut I didn't see it was a car horn.

Is the name of the vehicle datablock 'testcar' and does Add-ons/sound/horn.wav exist?

How do you play a sound on shift?

I think it's slot 2, that may only work for players though.