Game Development Community

stateAllowImageChange always allowing image to change

by David Robert Pemberton · in Torque Game Engine Advanced · 02/16/2009 (4:50 am) · 6 replies

I have set up a weapon with reload animations.

I have set my states up and scripts.

I have only one place that fire is allowed

stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateTransitionOnTriggerDown[2]  = "Fire";
   stateAllowImageChange[2]         = false;

   stateAllowImageChange[2]         = false;
   stateWaitForTimeout[2]           = true;

this all works fine till the reload.

stateName[6]                     = "ReloadClip";
   stateTimeoutValue[6]             = 1.4;
   stateTransitionOnTimeout[6]      = "Ready";
   stateSequence[6]                 = "ReloadClip";

   stateAllowImageChange[6]         = false;
   stateWaitForTimeout[6]           = true;

the reload animation is playing for a very short time and the gun just keeps on firing if the button is kept depressed.
stateAllowImageChange[6]         = false;
   stateWaitForTimeout[6]           = true;
don't make the slightest difference.
I was under the impression (maybe wrongly) that they where suposed to halt the state change till the current state had timed out.

If I put
stateTransitionOnTriggerDown[6]  = "";
nothing happens or if
stateTransitionOnTriggerDown[6]  = "ReloadClip";
is used the script halts till I take my finger off the trigger, but if I hit fire again real quick it breaks the animation again.

Is there a way of getting the stateAllowImageChange to not allow image changes and stateWaitForTimeout to wait for the timeout time?

About the author

http://www.deadlyassets.com I have a love of computers and programming them, have written a few games (ADV, Demon's Domain to name a couple) and even a couple of engines lost in the distant past of floppy disks


#1
02/16/2009 (1:10 pm)
Anyone any Ideas on this?

I have even tried changing the default values in engine\source\T3D\shapeImage.cpp
but with no change, seems Its bust.

Shame as It rather messes up all my weapons, without state based reloads. I'll have to change the engine.

Hmm is there no way I can delay a state change from script?
#2
02/16/2009 (2:15 pm)
After delving a bit deeper into the C++ seems I have got the wrong idea, the code that dosn't seem to be working correctly is :-
stateTimeoutValue[6]             = 1.4;
stateWaitForTimeout[6]           = true;
If the trigger is pulled within the 1.4 seconds the weapon is changing state to the fire state.

All I want it to do is wait the full 1.4 seconds before changing to the next state.

Anyone any Ideas.

The reason I'm not goint down the timer route is I want my weapon to auto reload when ammo is picked up, as well as when it runs out of ammo and it reloads the next clip.

All these scripts are working and all would be well IF I could stateWaitForTimeout before it processed the trigger pull in the ready state.

If I single shot all the time the scripts work (so long as I don't single shot while Its reloading. Then It fires upwards as the barrel is in that direction)
#3
02/16/2009 (9:11 pm)
Could you please post your entire ShapeImageData definition?
#4
02/17/2009 (4:22 am)
never mind, cured the problem
was an error in my state code.

thx anyway :)
#5
02/17/2009 (4:24 am)
I found it while tidying it up so I could post it here,
took me a day or so to see it.

Sometimes you just have to take a break and not stare at the code to see the error infront of you :)