Reload Animation and fire flash
by Gabriele B. · in Torque Game Engine · 05/26/2007 (12:16 am) · 5 replies
Hi,i have a simple weapon animation with reload function but sometime the reload weapon animation are not showed even if the OnReload are called...how is possible ?
Now the strange effect :
If i remove "stateSequenceRandomFlash[3] = true;" in the script all work good....please help me O.O
Thanks in advance for some idea.
P.S Sorry for my bad english
P.S This is the script
//--------------------------------------
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.5;
//--------------------------------------
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.5;
// 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
stateName[3] = "Fire";
stateSequence[3] = "Fire";
stateSequenceRandomFlash[3] = true; // IF REMOVED ALL WORK O.o
stateTimeoutValue[3] = 0.07;
stateFire[3] = true;
stateRecoil[3] = NoRecoil;
stateAllowImageChange[3] = false;
stateScript[3] = "onFire";
stateSound[3] = ChaingunFireSound;
stateTransitionOnNoAmmo[3] = "NoAmmo";
stateTransitionOnTriggerUp[3] = "Ready";
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.5;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateScript[4] = "onReload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
// 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";
stateTimeoutValue[5] = 0.1;
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 0.1;
stateTransitionOnTimeout[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
Now the strange effect :
If i remove "stateSequenceRandomFlash[3] = true;" in the script all work good....please help me O.O
Thanks in advance for some idea.
P.S Sorry for my bad english
P.S This is the script
//--------------------------------------
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.5;
//--------------------------------------
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.5;
// 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
stateName[3] = "Fire";
stateSequence[3] = "Fire";
stateSequenceRandomFlash[3] = true; // IF REMOVED ALL WORK O.o
stateTimeoutValue[3] = 0.07;
stateFire[3] = true;
stateRecoil[3] = NoRecoil;
stateAllowImageChange[3] = false;
stateScript[3] = "onFire";
stateSound[3] = ChaingunFireSound;
stateTransitionOnNoAmmo[3] = "NoAmmo";
stateTransitionOnTriggerUp[3] = "Ready";
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.5;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateScript[4] = "onReload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
// 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";
stateTimeoutValue[5] = 0.1;
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 0.1;
stateTransitionOnTimeout[6] = "NoAmmo";
stateTransitionOnAmmo[6] = "Reload";
About the author
#2
I can't remove it :(
05/26/2007 (12:28 am)
Hi Tim,i have a spinning animation on the dts, and the fire flash work correctly.I can't remove it :(
#3
It works perfectly for me - so give it a try. Goodluck.
05/26/2007 (12:35 am)
Well, if your weapon uses a spinning animation, your state system should look something like this:// Initial start up state //-------------------------------------- stateName[0] = "Preactivate"; stateTransitionOnLoaded[0] = "Activate"; stateTransitionOnNoAmmo[0] = "NoAmmo"; //-------------------------------------- stateName[1] = "Activate"; stateSequence[1] = "Activate"; stateSound[1] = WeaponUseSound; stateTimeoutValue[1] = 0.7; stateTransitionOnTimeout[1] = "Ready"; //-------------------------------------- stateName[2] = "Ready"; stateScript[2] = "setImage"; stateSpinThread[2] = Stop; stateTransitionOnTriggerDown[2] = "Spinup"; stateTransitionOnNoAmmo[2] = "NoAmmo"; //-------------------------------------- stateName[3] = "NoAmmo"; stateScript[3] = "onReload"; stateSpinThread[3] = Stop; stateTransitionOnAmmo[3] = "Reload"; stateSequence[3] = "NoAmmo"; stateTransitionOnTriggerDown[3] = "DryFire"; //-------------------------------------- stateName[4] = "Spinup"; stateSpinThread[4] = SpinUp; stateSound[4] = VulcanSpinupSound; stateTimeoutValue[4] = 0.5; stateWaitForTimeout[4] = false; stateTransitionOnTimeout[4] = "Fire"; stateTransitionOnTriggerUp[4] = "Spindown"; //-------------------------------------- stateName[5] = "Fire"; stateSequence[5] = "Fire"; stateSequenceRandomFlash[5] = true; stateSpinThread[5] = FullSpeed; stateSound[5] = VulcanFireSound; stateRecoil[5] = LightRecoil; stateAllowImageChange[5] = false; stateScript[5] = "onFire"; stateFire[5] = true; stateEjectShell[5] = true; stateTimeoutValue[5] = 0.1; stateTransitionOnTimeout[5] = "Fire"; stateTransitionOnTriggerUp[5] = "Spindown"; stateTransitionOnNoAmmo[5] = "EmptySpindown"; //-------------------------------------- stateName[6] = "Spindown"; stateSound[6] = VulcanSpinDownSound; stateSpinThread[6] = SpinDown; stateTimeoutValue[6] = 1.0; stateWaitForTimeout[6] = true; stateTransitionOnTimeout[6] = "Ready"; stateTransitionOnTriggerDown[6] = "Spinup"; //-------------------------------------- stateName[7] = "EmptySpindown"; stateSound[7] = VulcanSpinDownSound; stateSpinThread[7] = SpinDown; stateTimeoutValue[7] = 0.5; stateTransitionOnTimeout[7] = "NoAmmo"; //-------------------------------------- stateName[8] = "Reload"; stateTransitionOnNoAmmo[8] = "NoAmmo"; stateTransitionOnTimeout[8] = "Ready"; stateTimeoutValue[8] = 2.0; stateAllowImageChange[8] = false; stateSequence[8] = "Reload"; stateEjectShell[8] = false; //-------------------------------------- stateName[9] = "DryFire"; stateSound[9] = VulcanDryFireSound; stateTimeoutValue[9] = 0.5; stateTransitionOnTimeout[9] = "NoAmmo";You'll need to modify that to suit the behaviour of your weapon. Take note of all the "StateSpinThread"s - they control the spinning animation. Also, the above setup caters to a muzzle flash.
It works perfectly for me - so give it a try. Goodluck.
#4
My Dts is a Rifle not a ChainGun and contains Fire,Fire_Vis,Reload animation but not Spin animation can be this the problem ? Fire_Vis is related to Spin ?
P.S
You have a small example with reload animation and stateSequenceRandomFlash active ?
Thanks in advance
05/26/2007 (2:21 am)
Same problem :(My Dts is a Rifle not a ChainGun and contains Fire,Fire_Vis,Reload animation but not Spin animation can be this the problem ? Fire_Vis is related to Spin ?
P.S
You have a small example with reload animation and stateSequenceRandomFlash active ?
Thanks in advance
#5
- This method don't use stateSequenceRandomFlash
- Dts contains only two animation : Fire_Vis and Reload
- Fire_vis use the visibility track for muzzle flash.
//--------------------------------------
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.5;
//--------------------------------------
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.5;
// stateSequence[1] = "Activate";
// stateScript[1] = "onActivate";
// 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
stateName[3] = "Fire";
stateSequence[3] = "Fire_Vis";
stateTimeoutValue[3] = 0.07;
stateFire[3] = true;
stateRecoil[3] = NoRecoil;
stateAllowImageChange[3] = false;
stateScript[3] = "onFire";
stateSound[3] = ChaingunFireSound;
stateTransitionOnNoAmmo[3] = "NoAmmo";
stateTransitionOnTriggerUp[3] = "Ready";
stateTransitionOnTimeout[3] = "Fire";
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 2;
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";
stateTimeoutValue[5] = 0.1;
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 0.1;
stateTransitionOnTimeout[6] = "NoAmmo";
stateScript[6] = "onNoAmmo";
};
function WeaponImage::onNoAmmo(%this, %obj, %slot)
{
%obj.setInventory(%this.ammo,%this.ammo.maxInventory);
}
05/26/2007 (4:21 am)
Problem solved with a trick i think can be usefull for others :- This method don't use stateSequenceRandomFlash
- Dts contains only two animation : Fire_Vis and Reload
- Fire_vis use the visibility track for muzzle flash.
//--------------------------------------
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
stateTransitionOnTimeout[0] = "Ready";
stateTimeoutValue[0] = 0.5;
//--------------------------------------
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.5;
// stateSequence[1] = "Activate";
// stateScript[1] = "onActivate";
// 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
stateName[3] = "Fire";
stateSequence[3] = "Fire_Vis";
stateTimeoutValue[3] = 0.07;
stateFire[3] = true;
stateRecoil[3] = NoRecoil;
stateAllowImageChange[3] = false;
stateScript[3] = "onFire";
stateSound[3] = ChaingunFireSound;
stateTransitionOnNoAmmo[3] = "NoAmmo";
stateTransitionOnTriggerUp[3] = "Ready";
stateTransitionOnTimeout[3] = "Fire";
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 2;
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";
stateTimeoutValue[5] = 0.1;
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 0.1;
stateTransitionOnTimeout[6] = "NoAmmo";
stateScript[6] = "onNoAmmo";
};
function WeaponImage::onNoAmmo(%this, %obj, %slot)
{
%obj.setInventory(%this.ammo,%this.ammo.maxInventory);
}
Torque Owner Tim Heldna
Long story short; don't use that setting unless you're using a state system that includes the state spin threads.