Basic Weapon Setup
by Jon Law · 11/27/2005 (10:45 pm) · 16 comments
Step One: Modeling
The first step of this tutorial is simply to model a gun. Take your favorite 3D modeling software and get started. I personally use Maya 6.0 because i am a mac person but, to each his own. You will also need a model of an ammo box or ammo clip as well as a model of a bullet or arrow or whatever your projectile is going to be. here are my mine
ammo
projectile
make sure you froze transformations and rotations on your models and make sure they are oriented corectly
Anyways once you have settled on a good (low poly, of course) gun model and have textured it its time to set up your model for .dts export so open up your gun model and get ready...
Step Two: Node setup
In order for torque to understand that your making a weapon, we have to give our model certain nodes, which are basically reference points the the engine uses. These nodes include
mountPoint (the point in which the gun is attached to the hand of your character)
muzzlePoint (where the projectiles are fired from)
these are not the only nodes that you can include but these are the required ones.
For you maya users i suggest you download maya2dts and study the documentation
www.dannyngan.com/torque/maya2dts/
the best way to set up these nodes is the use maya2dts which simply has a function to create nodes, then all you have to do is rename them as mountPoint and muzzlePoint. If your not using the maya2dif simply create empty sets and name them accordingly.
place your mountPoint node where you want your character to hold the weapon and place the muzzlePoint at, you guessed it, the muzzle or barrel of the gun.
here is my set up
note: be carful of how your nodes are oriented. remember maya axis are set up differently and you have to accomadate for that.
Step Three: Hierarchy setup
use the maya2dts to embed your shape and register details on your weapon. place your nodes within the hierarchy so that is looks like this
your probably wondering what the sequence node is well read on...
Step Four: Animations
Animations are not 100% necesary, your gunu will work fine without them, however they will have much more character with animations. we are going to do one animation and you can use the principal to make others.
you start by using the maya2dts plugin to make a new sequence node. rename the node to "Sequence_Fire" (without quotes) change the start and end frames so that they go from 1-30 or however long you want your "fire" animation to be.
next simply animate the gun moving as if it had just been fired (a slight recoile)
thats it, youve just set up your first animation.
you can set up others by making more sequence nodes and setting the start and end frames to begin after the fire sequence is over. some other popular sequences are
Reload
NoAmmo
Activate (when they gun is first mounted)
there is one more step before we export and that is the .cfg file. create a new text document and name it "myshape.cfg" where my shape should be replaced with whatever you named your gun file. in this file simply type the following.
this file is used to ensure that all your nodes get exported.
thats about it, double check your heirarchy, make a new folder in example/yourgame/data/shapes/
and export your dts to that folder. make sure you also add any textures to that folder as well. Also now would be a good time to export your ammo box and projectile to that same folder. they need to exported as a regular .dts with bounds etc.
Step Five: The following is an example script that you would use in your game to control how your gun behaves. in my example i will use a pistol, the basic outline for this code was taken from crossbow.cs and edited down to make it more readable:
in either case mad sure you edit the code so that they file names match up with the ones your using (for example: mine refers to pistol.dts but you may have named your mygreatgun.dts) also check the names for the ammo box .dts and for the projectile .dts.
once you have checked over your code place this file in your /example/yourgamename/server/scripts folder and name it pistol.cs
you will need to edit some existing scripts in order to get your gun into the game add the following
starter.fps/server/scripts/game.cs, function onServerCreated():
exec("./pistol.cs");
starter.fps/server/scripts/player.cs, datablock PlayerData(PlayerBody):
maxInv[pistol] = 1 ;
maxInv[pistolAmmo] = 100 ;
starter.fps/client/scripts/default.bind.cs, at end:
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"pistol\");", "");
starter.fps/client/config.cs, at end:
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"pistol\");", "");
the only other thing is to add sound effects. find a good sound effect i personally like
www.findsounds.com
download appropriate gun sound effects (reloading, exploding, firing etc) and place them in your example/yourgame/data/sound folder
thats about it.. all you have to do now is go into torque load up a mission and open the mission editor. in shapes under weapons there should now be a pistol that you can add and under ammo there should be your ammo box. test out your weapon ensure that it mounts properly and it fire corretly.
thats all for now. if there are any questions, ask, it was very late when i wrote this so if anything is unclear or if i left somthing out ask.
The first step of this tutorial is simply to model a gun. Take your favorite 3D modeling software and get started. I personally use Maya 6.0 because i am a mac person but, to each his own. You will also need a model of an ammo box or ammo clip as well as a model of a bullet or arrow or whatever your projectile is going to be. here are my mine
ammo
projectilemake sure you froze transformations and rotations on your models and make sure they are oriented corectly
Anyways once you have settled on a good (low poly, of course) gun model and have textured it its time to set up your model for .dts export so open up your gun model and get ready...
Step Two: Node setup
In order for torque to understand that your making a weapon, we have to give our model certain nodes, which are basically reference points the the engine uses. These nodes include
mountPoint (the point in which the gun is attached to the hand of your character)
muzzlePoint (where the projectiles are fired from)
these are not the only nodes that you can include but these are the required ones.
For you maya users i suggest you download maya2dts and study the documentation
www.dannyngan.com/torque/maya2dts/
the best way to set up these nodes is the use maya2dts which simply has a function to create nodes, then all you have to do is rename them as mountPoint and muzzlePoint. If your not using the maya2dif simply create empty sets and name them accordingly.
place your mountPoint node where you want your character to hold the weapon and place the muzzlePoint at, you guessed it, the muzzle or barrel of the gun.
here is my set up
note: be carful of how your nodes are oriented. remember maya axis are set up differently and you have to accomadate for that.Step Three: Hierarchy setup
use the maya2dts to embed your shape and register details on your weapon. place your nodes within the hierarchy so that is looks like this
your probably wondering what the sequence node is well read on...Step Four: Animations
Animations are not 100% necesary, your gunu will work fine without them, however they will have much more character with animations. we are going to do one animation and you can use the principal to make others.
you start by using the maya2dts plugin to make a new sequence node. rename the node to "Sequence_Fire" (without quotes) change the start and end frames so that they go from 1-30 or however long you want your "fire" animation to be.
next simply animate the gun moving as if it had just been fired (a slight recoile)
thats it, youve just set up your first animation.
you can set up others by making more sequence nodes and setting the start and end frames to begin after the fire sequence is over. some other popular sequences are
Reload
NoAmmo
Activate (when they gun is first mounted)
there is one more step before we export and that is the .cfg file. create a new text document and name it "myshape.cfg" where my shape should be replaced with whatever you named your gun file. in this file simply type the following.
AlwaysExport: MountPoint MuzzlePointsave this file in the same directory as your maya file.
this file is used to ensure that all your nodes get exported.
thats about it, double check your heirarchy, make a new folder in example/yourgame/data/shapes/
and export your dts to that folder. make sure you also add any textures to that folder as well. Also now would be a good time to export your ammo box and projectile to that same folder. they need to exported as a regular .dts with bounds etc.
Step Five: The following is an example script that you would use in your game to control how your gun behaves. in my example i will use a pistol, the basic outline for this code was taken from crossbow.cs and edited down to make it more readable:
//-----------------------------------------------------------------------------
// pistol weapon. This file contains all the items related to this weapon
// including explosions, ammo, the item and the weapon item image.
// These objects rely on the item & inventory support system defined
// in item.cs and inventory.cs
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Sounds profiles
datablock AudioProfile(pistolReloadSound)
{
filename = "~/data/sound/pistol_reload.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(pistolFireSound)
{
filename = "~/data/sound/pistol_firing.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(pistolFireEmptySound)
{
filename = "~/data/sound/crossbow_firing_empty.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(pistolExplosionSound)
{
filename = "~/data/sound/pistol_explosion.wav";
description = AudioDefault3d;
preload = true;
};
//-----------------------------------------------------------------------------
// pistol bullets projectile particles
//This datablock defines what particles will be
//emited when the proectile is fired
datablock ParticleData(pistolBoltParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.1; // rises slowly
inheritedVelFactor = 0.0;
lifetimeMS = 150;
lifetimeVarianceMS = 10; // ...more or less
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.1 0.1 0.1 1.0";
colors[1] = "0.1 0.1 0.1 1.0";
colors[2] = "0.1 0.1 0.1 0";
sizes[0] = 0.05;
sizes[1] = 0.10;
sizes[2] = 0.15;
times[0] = 0.0;
times[1] = 0.3;
times[2] = 1.0;
};
datablock ParticleEmitterData(pistolBoltEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0.0;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 90.0;
particles = pistolBoltParticle;
};
//-----------------------------------------------------------------------------
// bullet Explosion
datablock ParticleData(pistolExplosionFire)
{
textureName = "~/data/shapes/particles/fire";
dragCoeffiecient = 100.0;
gravityCoefficient = 0;
inheritedVelFactor = 0.25;
constantAcceleration = 0.1;
lifetimeMS = 500;
lifetimeVarianceMS = 100;
useInvAlpha = false;
spinRandomMin = -80.0;
spinRandomMax = 80.0;
colors[0] = "0.8 0.4 0 0.8";
colors[1] = "0.2 0.0 0 0.8";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.3;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(pistolExplosionFireEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0.8;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 180.0;
lifetimeMS = 150;
particles = "pistolExplosionFire";
};
datablock ParticleData(pistolExplosionSparks)
{
textureName = "~/data/shapes/particles/spark";
dragCoefficient = 1;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 350;
colors[0] = "0.60 0.40 0.30 1.0";
colors[1] = "0.60 0.40 0.30 1.0";
colors[2] = "1.0 0.40 0.30 0.0";
sizes[0] = 0.25;
sizes[1] = 0.15;
sizes[2] = 0.15;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(pistolExplosionSparkEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 10;
velocityVariance = 1;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 100;
particles = "pistolExplosionSparks";
};
datablock ExplosionData(pistolExplosion)
{
soundProfile = pistolExplosionSound;
lifeTimeMS = 1000;
// Volume particles
particleEmitter = pistolExplosionFireEmitter;
particleDensity = 20;
particleRadius = 1;
// Point emission
emitter[0] = pistolExplosionSmokeEmitter;
emitter[1] = pistolExplosionSparkEmitter;
// Turned off..
shakeCamera = false;
impulseRadius = 0;
lightStartRadius = 0;
lightEndRadius = 0;
// Impulse
impulseRadius = 10;
impulseForce = 15;
// Dynamic light
lightStartRadius = 2;
lightEndRadius = 1;
lightStartColor = "0.5 0.5 0";
lightEndColor = "0 0 0";
};
//-----------------------------------------------------------------------------
// Projectile Object
datablock ProjectileData(pistolProjectile)
{
projectileShapeName = "~/data/shapes/pistol/projectile.dts";
directDamage = 20;
radiusDamage = 0;
damageRadius = 1;
explosion = pistolExplosion;
particleEmitter = pistolBoltEmitter;
muzzleVelocity = 700;
velInheritFactor = 0.3;
armingDelay = 0;
lifetime = 5000;
fadeDelay = 5000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0.00;
hasLight = true;
lightRadius = 1;
lightColor = "0.5 0.5 0.25";
hasWaterLight = true;
waterLightColor = "0 0.5 0.5";
};
function pistolProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"pistolrounds");
// Radius damage is a support scripts defined in radiusDamage.cs
// Push the contact point away from the contact surface slightly
// along the contact normal to derive the explosion center. -dbs
radiusDamage
(%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
%this.damageRadius,%this.radiusDamage,"Radius",40);
}
//-----------------------------------------------------------------------------
// Ammo Item
datablock ItemData(pistolAmmo)
{
// Mission editor category
category = "Ammo";
// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";
// Basic Item properties
shapeFile = "~/data/shapes/pistol/pistolammo.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
// Dynamic properties defined by the scripts
pickUpName = "Pistol Rounds";
maxInventory = 20;
};
//--------------------------------------------------------------------------
// Weapon Item. This is the item that exists in the world, i.e. when it's
// been dropped, thrown or is acting as re-spawnable item. When the weapon
// is mounted onto a shape, the pistolImage is used.
datablock ItemData(pistol)
{
// Mission editor category
category = "Weapon";
// Hook into Item Weapon class hierarchy. The weapon namespace
// provides common weapon handling functions in addition to hooks
// into the inventory system.
className = "Weapon";
// Basic Item properties
shapeFile = "~/data/shapes/pistol/pistol.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
emap = true;
// Dynamic properties defined by the scripts
pickUpName = "a Pistol";
image = pistolImage;
};
//--------------------------------------------------------------------------
// pistol image which does all the work. Images do not normally exist in
// the world, they can only be mounted on ShapeBase objects.
datablock ShapeBaseImageData(pistolImage)
{
// Basic Item properties
shapeFile = "~/data/shapes/pistol/pistol.dts";
emap = false;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
eyeOffset = "0.1 0.4 -0.6";
// 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 = false;
// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";
// Projectile && Ammo.
item = pistol;
ammo = pistolAmmo;
projectile = pistolProjectile;
projectileType = Projectile;
// 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.6;
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.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = pistolFireSound;
// Play the reload animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.8;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
//stateSound[4] = pistolReloadSound;
// 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] = 1.0;
stateTransitionOnTimeout[6] = "NoAmmo";
stateSound[6] = pistolFireEmptySound;
};
//-----------------------------------------------------------------------------
function pistolImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,1);
%currentAmmo = %obj.getInventory(%this.ammo);
%obj.client.setAmmoAmountHud(%currentAmmo);
// Determin initial projectile velocity based on the
// gun's muzzle point and the object's current velocity
%muzzleVector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%muzzleVelocity = VectorAdd(
VectorScale(%muzzleVector, %projectile.muzzleVelocity),
VectorScale(%objectVelocity, %projectile.velInheritFactor));
// Create the projectile object
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}at first this code my seem a little daunting but dont fear. most of it is just defining particle emission, this of course is a very watered down version. more emitters and particle data would need to be added for water explosions etc. if you want you can copy your crossbow.cs file and rename is pistol.cs or just use this one.in either case mad sure you edit the code so that they file names match up with the ones your using (for example: mine refers to pistol.dts but you may have named your mygreatgun.dts) also check the names for the ammo box .dts and for the projectile .dts.
once you have checked over your code place this file in your /example/yourgamename/server/scripts folder and name it pistol.cs
you will need to edit some existing scripts in order to get your gun into the game add the following
starter.fps/server/scripts/game.cs, function onServerCreated():
exec("./pistol.cs");
starter.fps/server/scripts/player.cs, datablock PlayerData(PlayerBody):
maxInv[pistol] = 1 ;
maxInv[pistolAmmo] = 100 ;
starter.fps/client/scripts/default.bind.cs, at end:
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"pistol\");", "");
starter.fps/client/config.cs, at end:
moveMap.bindCmd(keyboard, "2", "commandToServer('use',\"pistol\");", "");
the only other thing is to add sound effects. find a good sound effect i personally like
www.findsounds.com
download appropriate gun sound effects (reloading, exploding, firing etc) and place them in your example/yourgame/data/sound folder
thats about it.. all you have to do now is go into torque load up a mission and open the mission editor. in shapes under weapons there should now be a pistol that you can add and under ammo there should be your ammo box. test out your weapon ensure that it mounts properly and it fire corretly.
thats all for now. if there are any questions, ask, it was very late when i wrote this so if anything is unclear or if i left somthing out ask.
#2
11/28/2005 (2:41 pm)
Thank you!
#4
I'm in the process at figuring out how to compile a version based on the Win 6.5 but this kind of thing is not my strength.
Any help or direction will be appreciated.
Cheers!
12/13/2005 (4:19 am)
Jonathan, you mention you're using Maya 6.5 on a Mac. What dts exporter are you using as the only current one I can find is 6.0.I'm in the process at figuring out how to compile a version based on the Win 6.5 but this kind of thing is not my strength.
Any help or direction will be appreciated.
Cheers!
#5
12/17/2005 (11:05 am)
Sorry james, that was a typo im actually using 6.0 but i heard that there are plans to recompile maya2dts for 6.5
#6
01/31/2006 (6:29 am)
I am a Maya user on the Mac platform and was looking for info on how to make weapons. I have just completed my first character model and wanted to make weapons for it but had no idea how to do so. This single resource answered all my questions. Thanks for that
#7
08/18/2006 (5:25 am)
when you do this, or at least, when I do this, you get a weapon with a pistol model and all, but scriptwise it doesnt really behave like a pistol. this weapon fires automaticly, tho u want a semi-auto gun for ur pistol, how do u do that?
#8
note: x is any valid number for the state
stateName[x]="WaitForRelease";
stateTransitionOnTriggerUp[x]="Reload"; //We only move on to the next state when the player releases the trigger
The final state machine would look something like this:
// 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.6;
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] = "WaitForRelease"; //<==
stateTimeoutValue[3] = 0.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = pistolFireSound;
//Wait for the player to release the trigger
stateName[4]="WaitForRelease";
stateTransitionOnTriggerUp[4]="Reload"; //Now torque will change state when the player releases the trigger
// Play the reload animation, and transition into
stateName[5] = "Reload";
stateTransitionOnNoAmmo[5] = "NoAmmo";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.8;
stateAllowImageChange[5] = false;
stateSequence[5] = "Reload";
stateEjectShell[5] = true;
//stateSound[5] = pistolReloadSound;
// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
stateSequence[6] = "NoAmmo";
stateTransitionOnTriggerDown[6] = "DryFire";
// No ammo dry fire
stateName[7] = "DryFire";
stateTimeoutValue[7] = 1.0;
stateTransitionOnTimeout[7] = "NoAmmo";
stateSound[7] = pistolFireEmptySound;
08/25/2006 (3:32 pm)
@Tijs Karman: If you want the weapon to fire semi-auto then you need to wait for the player to release the trigger. To do that, add an extra state between Fire and Reload, let's call it WaitForRelease, and then modify stateTransitionOnTimeout[3] so that it points to WaitForRelease. The WaitForRelease state would look like this:note: x is any valid number for the state
stateName[x]="WaitForRelease";
stateTransitionOnTriggerUp[x]="Reload"; //We only move on to the next state when the player releases the trigger
The final state machine would look something like this:
// 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.6;
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] = "WaitForRelease"; //<==
stateTimeoutValue[3] = 0.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = pistolFireSound;
//Wait for the player to release the trigger
stateName[4]="WaitForRelease";
stateTransitionOnTriggerUp[4]="Reload"; //Now torque will change state when the player releases the trigger
// Play the reload animation, and transition into
stateName[5] = "Reload";
stateTransitionOnNoAmmo[5] = "NoAmmo";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.8;
stateAllowImageChange[5] = false;
stateSequence[5] = "Reload";
stateEjectShell[5] = true;
//stateSound[5] = pistolReloadSound;
// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
stateSequence[6] = "NoAmmo";
stateTransitionOnTriggerDown[6] = "DryFire";
// No ammo dry fire
stateName[7] = "DryFire";
stateTimeoutValue[7] = 1.0;
stateTransitionOnTimeout[7] = "NoAmmo";
stateSound[7] = pistolFireEmptySound;
#9
thanks for posting
08/25/2006 (11:38 pm)
yup, worked fine. should have figured that myself tho ;P anyways this will help other people a lot too.thanks for posting
#10
11/06/2006 (7:25 pm)
I should love to try this out.. Is it possible to have the exact resources you used? Oh I can use a projectile, gun and ammobox dts no problem, but it's more the particles (to better understand how they work)
#11
11/20/2006 (8:48 am)
#12
11/20/2006 (8:48 am)
#13
11/20/2006 (9:43 am)
#14
copy and paste the above! Not sure if you still have this issue but...... You also need to put this line of code at the end of the ......\client\scripts\default.bind.cs (below)
moveMap.bindCmd(keyboard, "2", "commandToServer(\'use\',\"pistol\");", "");
11/21/2006 (9:56 pm)
moveMap.bindCmd(keyboard, "2", "commandToServer(\'use\',\"pistol\");", "");copy and paste the above! Not sure if you still have this issue but...... You also need to put this line of code at the end of the ......\client\scripts\default.bind.cs (below)
moveMap.bindCmd(keyboard, "2", "commandToServer(\'use\',\"pistol\");", "");
#16
See the thing is, you don't usually hold pistols with two hands like you do with rifles do you? I want my player to hold the pistol with one hand so help plz!!. And one more thing,
--------------------
/ / / <<<<<
/ / / the player grab onto the handle?
06/10/2008 (12:07 am)
This is great, but there's one little problem...See the thing is, you don't usually hold pistols with two hands like you do with rifles do you? I want my player to hold the pistol with one hand so help plz!!. And one more thing,
--------------------
/ / / <<<<<

Torque Owner Josh Williams
Default Studio Name