Vehicle sounds
by CodingChris · in Torque Game Engine · 10/05/2007 (1:13 am) · 10 replies
Hi,
I want to add sounds to my vehicle. I made this:
I want to add sounds to my vehicle. I made this:
datablock AudioProfile(CarSoftImpactSound)
{
filename = "~/data/sound/car/softcrash.wav";
descrition = AudioClose3d;
preload = true;
};
datablock AudioProfile(CarHardImpactSound)
{
filename = "~/data/sound/car/hardcrash.wav";
descrition = AudioClose3d;
preload = true;
};
datablock AudioProfile(CarWheelImpactSound)
{
filename = "~/data/sound/car/wheelimpact.wav";
descrition = AudioClose3d;
preload = true;
};
datablock AudioProfile(CarThrustSound)
{
filename = "~/data/sound/car/engineaccel.wav";
descrition = AudioClose3d;
preload = true;
};
datablock AudioProfile(CarEngineSound)
{
filename = "~/data/sound/car/engineidle.wav";
descrition = AudioClose3d;
preload = true;
};
datablock AudioProfile(CarSquealSound)
{
filename = "~/data/sound/car/wheelsqueal.wav";
descrition = AudioClose3d;
preload = true;
};
...
datablock WheeledVehicleData(MyBot)
{
category = "Vehicles";
shapeFile = "~/data/shapes/buggy/buggy.dts";
emap = true;
tireDB = "DefaultCarTire";
springDB = "DefaultCarSpring";
maxDamage = 150;
destroyedLevel = 0.5;
maxSteeringAngle = 0.385; // Maximum steering angle, should match animation
tireEmitter = TireEmitter; // All the tires use the same dust emitter
// 3rd person camera settings
cameraRoll = true; // Roll the camera with the vehicle
cameraMaxDist = 4.8; // Far distance from vehicle
cameraOffset = 1.5; // Vertical offset from camera mount point
cameraLag = 0.26; // Velocity lag of camera
cameraDecay = 1.25; // Decay per sec. rate of velocity lag
// Rigid Body
mass = 380;
massCenter = "0 -0.2 0"; // Center of mass for rigid body
massBox = "0 0 0"; // Size of box used for moment of inertia,
// if zero it defaults to object bounding box
drag = 0.6; // Drag coefficient
bodyFriction = 0.6;
bodyRestitution = 0.4;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 8; // Physics integration: TickSec/Rate
collisionTol = 0.1; // Collision distance tolerance
contactTol = 0.1; // Contact velocity tolerance
// Engine
engineTorque = 5200; // Engine power
engineBrake = 600; // Braking when throttle is 0
brakeTorque = 8000; // When brakes are applied
maxWheelSpeed = 50; // Engine scale by current speed / max speed
// Energy
maxEnergy = 100;
jetForce = 3000;
minJetEnergy = 30;
jetEnergyDrain = 2;
// Sounds
jetSound = CarThrustSound;
engineSound = CarEngineSound;
squealSound = CarSquealSound;
softImpactSound = CarSoftImpactSound;
hardImpactSound = CarHardImpactSound;
wheelImpactSound = CarWheelImpactSound;
// explosion = VehicleExplosion;
};But I cannot here something. What's wrong here?About the author
#2
10/05/2007 (1:50 am)
The sound doesn't play, the sounds are not corrupted, the paths are correct and I cannot find a scripting error.
#3
Make sure your audio profiles exist and are being executed.
10/05/2007 (2:01 am)
The engine sound should be using a looping audio profile by the way.Make sure your audio profiles exist and are being executed.
#4
10/05/2007 (2:03 am)
Sorry, but what do you mean? The profiles are all in car.cs and car.cs is executed.
#5
As the car engine sound sounds continuously it needs to be a looping sound. This means that you need to use a looping sound description which should exist in server/scripts/audioProfiles.cs.
I made a typo above, I meant check that all your audio descriptions exist and are being executed.
This is how sounds work in Torque. They consist of an audio profile and an audio description. The audio profile tells the engine the path to the sound file and which audio description to use. The audio descriptions contains information about the volume, looping, is it 3D etc.
Does that help?
10/05/2007 (2:09 am)
datablock AudioProfile(CarEngineSound)
{
filename = "~/data/sound/car/engineidle.wav";
descrition = AudioClosestLooping3d; // <-- LOOK HERE
preload = true;
};As the car engine sound sounds continuously it needs to be a looping sound. This means that you need to use a looping sound description which should exist in server/scripts/audioProfiles.cs.
datablock AudioDescription(AudioClosestLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 30.0;
type = $SimAudioType;
};I made a typo above, I meant check that all your audio descriptions exist and are being executed.
This is how sounds work in Torque. They consist of an audio profile and an audio description. The audio profile tells the engine the path to the sound file and which audio description to use. The audio descriptions contains information about the volume, looping, is it 3D etc.
Does that help?
#6
10/05/2007 (2:18 am)
I've got no audio descriptions. Sorry, that's the first time, that I'm working with the audio functions. When I add your description and change my carenginesound audioprofile it does not work either.
#7
I.e. it should be in this order:
If the description is in a different script make sure that script is executed before your car script.
10/05/2007 (2:29 am)
Is your description above the profile?I.e. it should be in this order:
datablock AudioDescription(AudioClosestLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 30.0;
type = $SimAudioType;
};
datablock AudioProfile(CarEngineSound)
{
filename = "~/data/sound/car/engineidle.wav";
descrition = AudioClosestLooping3d;
preload = true;
};If the description is in a different script make sure that script is executed before your car script.
#8
10/05/2007 (3:09 am)
Now I looked again. All the descriptions are being executed and I changed the profiles like this:datablock AudioProfile(CarSoftImpactSound)
{
filename = "~/data/sound/car/softcrash.wav";
descrition = "AudioClose3d";
preload = true;
};and it still doesn't work.
#9
10/05/2007 (7:15 am)
Type: descrition should be description, maybe that will help!
#10
10/05/2007 (7:26 am)
Thanks, Dave... This misstake is a bit funny.
Torque Owner Tim Heldna
Test that the sounds actually work by typing this into the console once the game is loaded:
If the sound doesn't play then it's possible your sounds are corrupted, the paths to the Wav files are incorrect or that you have a scripting error somewhere.