Game Development Community

TGE - FlyingVehicle - EngineSound issue

by Iain Craig · in Torque Game Engine · 06/04/2006 (11:43 am) · 7 replies

Hi all,

I'm trying to use engineSound in a FlyingVehicle datablock. Other audio is working OK - I have AudioEmitters in the scene that work fine. No errors in console.log.

My FlyingVehicle is customised but I can't get engineSound to work with a stock one either.

Can anyone see anything obvious in the below?

Bestest,
Iain

#1
06/04/2006 (11:43 am)
~/client/audioProfiles.cs:

//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.

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

//--------------------------------------------------------------
// Channel assignments (channel 0 is unused in-game).
//--------------------------------------------------------------

$GuiAudioType     	= 1;
$SimAudioType     	= 2;
$MusicType 		  	= 3;
$AliceFXType	  	= 4;
$SystemEmittersType	= 5;

//--------------------------------------------------------------
// Basic audio descriptions
//--------------------------------------------------------------

new AudioDescription(AudioGui)
{
   volume   = 1.0;
   isLooping= false;
   is3D     = false;
   type     = $GuiAudioType;
};

new AudioDescription(AudioMessage)
{
   volume   = 1.0;
   isLooping= false;
   is3D     = false;
   type     = $MessageAudioType;
};

//--------------------------------------------------------------
// Music
//--------------------------------------------------------------

new AudioDescription(LoopingMusic)
{
   volume   = 1.0;
   isLooping = true;
   is3D     = false;
   type     = $AmbientAudioType;
};

new AudioProfile(Music_MainMenu)
{
	filename = "~/data/sound/menumusic.wav";
	description = "LoopingMusic";
	preload = false;
};

//--------------------------------------------------------------
// Alice
//--------------------------------------------------------------

new AudioDescription(AliceFX)
{
   volume   = 1.0;
   isLooping = true;
   is3D     = true;
   type     = $AliceFXType;
   referenceDistance = "20";
   maxDistance = "200";
};

// Jet

new AudioProfile(Alice_Jet)
{
	fileName = "~/data/sound/alice_jet.wav";
	description = "AliceFX";
	preload = true;
};

// Engine

new AudioProfile(Alice_Engine)
{
	fileName = "~/data/sound/alice_engine.wav";
	description = "AliceFX";
	preload = true;
};
#2
06/04/2006 (11:44 am)
~/server/alice.cs:

//--------------------------------------------------------------
// Particle systems
//--------------------------------------------------------------

// Jet

datablock ParticleData(AliceJetParticle)
{
  dragCoefficient      = 1.5;
  gravityCoefficient   = 0;
  inheritedVelFactor   = 0.2;
  constantAcceleration = 0.0;
  lifetimeMS           = 6000;
  lifetimeVarianceMS   = 0;
  textureName          = "~/data/particles/forwardParticle";
  colors[0]     		= "0 0 1 0.5";
  colors[1]     		= "0 0.2 1 0.5";
  sizes[0]      		= 1;
  sizes[1]      		= 15;
};

datablock ParticleEmitterData(AliceJetEmitter)
{
  ejectionPeriodMS 		= 50;
  periodVarianceMS 		= 0;
  ejectionVelocity 		= 1;
  velocityVariance 		= 1.0;
  ejectionOffset   		= 0.0;
  thetaMin         		= 0;
  thetaMax         		= 180;
  phiReferenceVel  		= 0;
  phiVariance      		= 360;
  overrideAdvances 		= false;
  particles 			= "AliceJetParticle";
};

// Contrail

datablock ParticleData(AliceContrailParticle)
{
  dragCoefficient      	= 1.5;
  gravityCoefficient   	= 0;
  inheritedVelFactor   	= 0.2;
  constantAcceleration 	= 0.0;
  lifetimeMS           	= 6000;
  lifetimeVarianceMS   	= 500;
  spinSpeed				= 20.0;
  spinRandomMin			= 2.0;
  spinRandomMax			= 20.0;
  textureName          	= "~/data/particles/trailParticle";
  colors[0]     	   	= "0.2 0.1 0.7 0.7";
  colors[1]     		= "0.1 0.3 0.7 0.7";
  sizes[0]      		= 2;
  sizes[1]      		= 5;
};

datablock ParticleEmitterData(AliceContrailEmitter)
{
  ejectionPeriodMS 		= 1;
  periodVarianceMS 		= 0.1;
  ejectionVelocity 		= 1;
  velocityVariance 		= 0.1;
  ejectionOffset   		= 0.0;
  thetaMin         		= 0;
  thetaMax         		= 180;
  phiReferenceVel  		= 0;
  phiVariance      		= 360;
  overrideAdvances 		= false;
  particles 			= "AliceContrailParticle";
};

//--------------------------------------------------------------
// Vehicles
//--------------------------------------------------------------

datablock FlyingVehicleData(Alice)
{
	spawnOffset						= "0 0 0";
	emap							= true;
	category						= "Ships";
	shapeFile						= "~/data/ships/alice.dts";
	multipassenger					= false;
	computeCRC						= true;
									
	drag							= 0.5;
	density							= 3.0;

	mountPose[0]					= sitting;
	numMountPoints					= 1;
	isProtectedMountPoint[0]		= true;
	cameraMaxDist					= 0.5;
	cameraOffset					= 2.5;	// Vertical offset from camera mount point
	cameraLag						= 0.0;
    cameraRoll 						= true; // Roll the camera with the vehicle

    // explosion						= DroneVehicleExplosion;
	explosionDamage					= 10.5;
	explosionRadius					= 15.0;

	maxDamage						= 50.40;
	destroyedLevel					= 50.40;
									
	isShielded						= true; 
	energyPerDamagePoint			= 160;
	maxEnergy						= 280;      // Afterburner and any energy weapon pool
	rechargeRate					= 0.8;

	minDrag							= 1;           // Linear Drag (eventually slows you down when not thrusting...constant drag)
	rotationalDrag					= 10;        // Anguler Drag (dampens the drift after you stop moving the mouse...also tumble drag)

	maxAutoSpeed					= 0;       // Autostabilizer kicks in when less than this speed. (meters/second)
	autoAngularForce				= 200;       // Angular stabilizer force (this force levels you out when autostabilizer kicks in)
	autoLinearForce					= 200;        // Linear stabilzer force (this slows you down when autostabilizer kicks in)
	autoInputDamping				= 0.95;      // Dampen control input so you don't' whack out at very slow speeds
    integration = 6;           					// Physics integration: TickSec/Rate
    collisionTol = 0.2;        					// Collision distance tolerance
    contactTol = 0.1;
   
	// Maneuvering
	maxSteeringAngle				= 2;    // Max radiens you can rotate the wheel. Smaller number is more maneuverable.
	horizontalSurfaceForce			= 6;   // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning)
	verticalSurfaceForce			= 4;     // Vertical center "wing" (controls side slip. lower numbers make MORE slide.)
	maneuveringForce				= 2400;      // Horizontal jets (W,S,D,A key thrust)
	steeringForce					= 60;         // Steering jets (force applied when you move the mouse)
	steeringRollForce				= 15;      // Steering jets (how much you heel over when you turn)
	rollForce						= 0;  // Auto-roll (self-correction to right you after you roll/invert)
	hoverHeight						= 45;       // Height off the ground at rest
	createHoverHeight				= 45;  // Height off the ground when created
	maxForwardSpeed					= 60;  // speed in which forward thrust force is no longer applied (meters/second)

	// Turbo Jet
	jetForce						= 3000;      // Afterburner thrust (this is in addition to normal thrust)
	minJetEnergy					= 28;     // Afterburner can't be used if below this threshhold.
	jetEnergyDrain					= 2.8;       // Energy use of the afterburners (low number is less drain...can be fractional)                                                                                                                                                                                                                                                                                          // Auto stabilize speed
	vertThrustMultiple				= 3.0;

	// Rigid body
	mass							= 10;        // Mass of the vehicle
	bodyFriction					= 0;     // Don't mess with this.
	bodyRestitution					= 1.0;   // When you hit the ground, how much you rebound. (between 0 and 1)
	minRollSpeed					= 2000;     // Don't mess with this.
	softImpactSpeed					= 3;       // Sound hooks. This is the soft hit.
	hardImpactSpeed					= 15;    // Sound hooks. This is the hard hit.

	// Ground Impact Damage (uses DamageType::Ground)
	minImpactSpeed					= 10;      // If hit ground at speed above this then it's an impact. Meters/second
	speedDamageScale				= 0.06;

	// Object Impact Damage (uses DamageType::Impact)
	collDamageThresholdVel			= 23.0;
	collDamageMultiplier			= 0.02;

	//
	minTrailSpeed					= 1;      // The speed your contrail shows up at.
	trailEmitter					= AliceContrailEmitter;
	forwardJetEmitter				= AliceJetEmitter;
	//downJetEmitter					= DroneJetEmitter;

	//
	jetSound						= Alice_Jet;
	engineSound						= Alice_Engine;
	
	triggerDustHeight				= 4.0;
	dustHeight						= 1.0;

	damageEmitterOffset[0]			= "0.0 -3.0 0.0 ";
	damageLevelTolerance[0]			= 0.3;
	damageLevelTolerance[1]			= 0.7;
	numDmgEmitterAreas				= 3;
						
	minMountDist					= 2;

	targetNameTag					= 'Alice';
									
	checkRadius						= 5.5;
	observeParameters				= "0 0 0";
									
	shieldEffectScale				= "0.937 1.125 0.60";
};
#3
06/05/2006 (7:24 am)
I haven't got anywhere getting this to work :(

Seeing as only the player in my game will be using the FlyingVehicle however, with a 1st-person or near 3rd-person camera, a 3D sound's maybe a bit of an overkill.

Maybe I can just adjust FlyingVehicle.cc to use a 2D sound and attenuate the volume based on the FlyingVehicle's current speed (mRigid.linVelocity.len();).
#4
06/05/2006 (8:22 am)
If your game is going to be multiplayer you might want to store your audio profile/description info on the server and not the client. Other than that your script looks fine. I don't have any problems with a flyingVehicles engine sound so I can only suggest the following:

- Try using a different wav sound
- Try using an ogg
- Don't see that it would make a difference but try moving your audio profiles/descriptions to the server.
- Try altering the length of your engine sound
#5
06/06/2006 (5:19 am)
Hi Tim,

This one's just singleplayer; I tried initially having audio profiles/descriptions on the server and only actually put them on the client when I couldn't get them to work serverside.

At your suggestion I've played with the length of the engine sound to no avail; at the moment I'm using 2 seconds of 400Hz sine wave for testing. The other emitters in my missions also use wavs rendered by Sound Forge so I don't think that's it.

I'd rather not use my manually-attenuated 2D sound idea (above) if possible but I'm still not getting this working.

I can't find an all-inclusive FlyingVehicle demo in any of the resources on the topic. Just in case I'm missing something obvious could someone who's had success possibly outline the steps they've taken to get a working FlyingVehicle engine sound? (eg start with fresh starter.racing, implement a resource such as this, add audioprofiles, etc)
#6
06/06/2006 (5:19 am)
As another thought, does anyone know a gotcha that would prevent this working if I was building from tutorial.base instead of starter.racing?
#7
06/06/2006 (7:19 am)
Well I've done a helicopter resource which uses an engine sound and is based on the flyingVehicle class. It's not a step by step tutorial but you might find it useful.

Helicopter Resource