Playing sounds
by D B · in Torque Game Engine · 03/22/2006 (3:06 pm) · 2 replies
I'm trying to create a function that will play a sound once when called. This is what it consists of:
function PlaySound(%s)
{
ServerPlay2D(%s);
}
In a separate file, I wanted to have all of the sound profiles there, so I could easily call upon them when needed. This is how I have my test sound set up:
new AudioProfile(test)
{
filename = "~/data/sound/Environment/thunder1.ogg";
description = "AudioNonLooping";
preload = true;
};
When I echo PlaySound(test); from the console, it creates a blank line under =>echo(PlaySound(test));, as if it can't find the profile or file location.
What is it I could be doing wrong?
Thank you.
function PlaySound(%s)
{
ServerPlay2D(%s);
}
In a separate file, I wanted to have all of the sound profiles there, so I could easily call upon them when needed. This is how I have my test sound set up:
new AudioProfile(test)
{
filename = "~/data/sound/Environment/thunder1.ogg";
description = "AudioNonLooping";
preload = true;
};
When I echo PlaySound(test); from the console, it creates a blank line under =>echo(PlaySound(test));, as if it can't find the profile or file location.
What is it I could be doing wrong?
Thank you.
About the author
Torque Owner Tim Heldna
datablock AudioProfile(test) { filename = "~/data/sound/Environment/thunder1.ogg"; description = "AudioNonLooping"; preload = true; };Make sure it's in server/scripts/audioProfiles.cs & NOT client/scripts/audioProfiles.cs
Since it's an environmental sound which you'd want to play across the server to all clients it should be located in the server side of things. Your audioProfile above is what you'd use for a client only sound like gui sound fx, which only play for the client & not across the network. This type of audioProfile is what goes into client/scripts/audioProfiles.