Game Development Community

Minigun/Chaingun Fire Sound Sequence Issue

by DavidRM · in Technical Issues · 02/02/2007 (1:44 pm) · 1 replies

I'm working on a minigun/chaingun. I have the states setup so that the gun works (or at least seems to) as expected.

What's going wrong, though, is that the fire sounds are, to quote someone who's heard them, "pseudorandom". I was looking for crisp, steady, sticatto bang-bang-bang. Instead I get bang-bang-pause-bang-pause-bang-bang-bang etc.

Here is the state script (summarized because 4096 characters isn't enough to post a *useful* amount of code):
...

   // Ready to fire, just waiting for the trigger
   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "Reload";
   stateTransitionOnTriggerDown[2]  = "SpinUp";
   stateSequence[2]                 = "Ready";

   // ready spin
   stateName[3]                     = "ReadySpin";
   stateTimeoutValue[3]             = 2.0;
   stateWaitForTimeout[3]           = false;
   stateTransitionOnTriggerDown[3]  = "Fire";
   stateTransitionOnTimeout[3]      = "SpinDown";
   stateSequence[3]                 = "SpinDown";
   stateSound[3]                    = MinigunSpinLoopSound;

   // spin up
   stateName[4]                     = "SpinUp";
   stateTimeoutValue[4]             = 1.1;
   stateWaitForTimeout[4]           = false;
   stateTransitionOnTimeout[4]      = "Fire";
   stateTransitionOnTriggerUp[4]    = "SpinDown";
   stateSequence[4]                 = "Fire";
   stateSound[4]                    = MinigunSpinUpSound;
   
   // spin down
   stateName[5]                     = "SpinDown";
   stateTimeoutValue[5]             = 1.5;
   stateWaitForTimeout[5]           = true;
   stateTransitionOnTimeout[5]      = "Ready";
   stateTransitionOnTriggerDown[5]  = "SpinUp";
   stateSequence[5]                 = "Ready";
   stateSound[5]                    = MinigunSpinDownSound;
   
   // Fire the weapon. Calls the fire script which does
   // the actual work.
   stateName[6]                     = "Fire";
   stateTimeoutValue[6]             = 0.085;
   stateWaitForTimeout[6]           = true;
   stateTransitionOnTimeout[6]      = "Fire";
   stateTransitionOnTriggerUp[6]    = "ReadySpin";
   stateTransitionOnNoAmmo[6]       = "ReloadSpinDown";
   stateFire[6]                     = true;
   stateRecoil[6]                   = LightRecoil;
   stateAllowImageChange[6]         = false;
   stateSequence[6]                 = "Fire";
   stateScript[6]                   = "onFire";
   stateSound[6]                    = MinigunFire1Sound;

   // Play the relead animation, and transition into
   ...

   stateName[10]                     = "ReloadSpinDown";
   stateTimeoutValue[10]             = 1.5;
   stateWaitForTimeout[10]           = true;
   stateTransitionOnTimeout[10]      = "ReloadHopper";
   stateAllowImageChange[10]         = false;
   stateSequence[10]                 = "ReloadHopper";
   stateScript[10]                   = "onReload";
   stateSound[10]                    = MinigunSpinDownSound;

   ...

   // Reload hopper
   stateName[13]                     = "ReloadHopper";
   stateTimeoutValue[13]             = 1.0;
   stateWaitForTimeout[13]           = true;
   stateTransitionOnTimeout[13]      = "ReloadHopperDone";
   stateSequence[13]                 = "ReloadHopperDone";
   stateScript[13]                   = "onReloadHopper";
   stateSound[13]                    = MinigunReloadPourSound;

   // Reload hopper done
   stateName[14]                     = "ReloadHopperDone";
   stateTimeoutValue[14]             = 0.1;
   stateWaitForTimeout[14]           = true;
   stateTransitionOnTimeout[14]      = "Ready";
   stateSequence[14]                 = "Ready";
   stateScript[14]                   = "onReloadHopperDone";

Is it a problem with the sound playback? Is the 0.085 interval too short? Is there something about the timeout that's not precise?

Any help would be appreciated.

-David

#1
02/02/2007 (2:19 pm)
Here's the MP5 code from the Skeleton Pack - which seems to work okay. Maybe you can use this and compare differences to fix the issue.

//--------------------------------------------------------------------------
// MP5 image which does all the work.  Images do not normally exist in
// the world, they can only be mounted on ShapeBase objects.

datablock ShapeBaseImageData(MP5Image)
{
   // Basic Item properties
   shapeFile = "~/data/shapes/weapons/MP5/MP5_dts.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   eyeOffset = "0.14 0.08 -0.25";
   offset = "0 0 0";
   
   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off.  
   correctMuzzleVector = true;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = MP5;
   ammo = MP5Ammo;
   projectile = MP5Projectile;
   projectileType = Projectile;
   casing = MP5Shell;

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
   stateName[0]                     = "Preactivate";
   stateTransitionOnLoaded[0]       = "Activate";
   stateTransitionOnNoAmmo[0]       = "NoAmmo";

   // Activating the gun.  Called when the weapon is first
   // mounted and there is ammo.
   stateName[1]                     = "Activate";
   stateTransitionOnTimeout[1]      = "Ready";
   stateTimeoutValue[1]             = 0.5;
   stateSequence[1]                 = "Activate";

   // Ready to fire, just waiting for the trigger
   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateTransitionOnTriggerDown[2]  = "Fire";

   // Fire the weapon. Calls the fire script which does
   // the actual work.
   stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.05;
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateEmitter[3]                  = mp5FireEmitter;
   stateEmitterTime[3]              = 0.15;
   stateSound[3]                    = MP5FireSound;

   // Play the reload animation, and transition into
   stateName[4]                     = "Reload";
   stateTransitionOnNoAmmo[4]       = "NoAmmo";
   stateTransitionOnTimeout[4]      = "Ready";
   stateTimeoutValue[4]             = 0.05;
   stateAllowImageChange[4]         = false;
   //stateSequence[4]                 = "Reload";
   stateEjectShell[4]               = true;

   // No ammo in the weapon, just idle until something
   // shows up. Play the dry fire sound if the trigger is
   // pulled.
   stateName[5]                     = "NoAmmo";
   stateTransitionOnAmmo[5]         = "Reload";
   stateSequence[5]                 = "NoAmmo";
   stateTransitionOnTriggerDown[5]  = "DryFire";

   // No ammo dry fire
   stateName[6]                     = "DryFire";
   stateTimeoutValue[6]             = 0.5;
   stateTransitionOnTimeout[6]      = "NoAmmo";
   stateSound[6]                    = MP5FireEmptySound;
};