Game Development Community

Weapon Animation

by Alexander B · in Torque Game Engine · 09/01/2009 (5:42 am) · 5 replies

How do i get a weapon animation in? By that I mean when I shoot the gun plays an animation.

Thanks in advance.

#1
09/01/2009 (6:02 am)
From crossbow.cs:
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]                    = CrossbowFireSound;
stateSequence is what you'll need to pay attention to.
#2
09/01/2009 (9:26 am)
Fire, and a few other animation names are hardcoded. So if you make an animation called "fire" and export it in the DTS model it will play automatically when you shoot.

Check the related cpp file (probably weapon.cpp) for a full list of pre-setup animation calls.
#3
09/01/2009 (9:36 am)
yes,'ambient' and 'spin' are hardcoded,
'Fire' works with stateSequence,it gets the string and calls findsequence(const char* ..)
#4
09/02/2009 (3:43 am)
Thanks i will get my 3d modeller to do that. How do i get rid of the sound as well?
#5
09/02/2009 (5:33 pm)
from crossbow.cs
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]                    = CrossbowFireSound; 
   ///*******

CrossbowFireSound is defined at the top of crossbow.cs

For the FireSound to truly be 3D it MUST be Mono (1 channel) format.

The sound should stop on its own so I'm not sure what you mean by "get rid of the sound".