Game Development Community

OnFire loop

by Wolfgang Kurz · in Torque Game Engine · 05/03/2007 (9:28 am) · 2 replies

Hello everyone,

I created a projectile and it has a onFire function of course which gets called when the client uses the mTriggerCount0 Global.

All i do on the Client is:

On a left click of the mouse i do mTriggerCount0++

but then the onfire Function gets called in a loop until i press the left mousebutton again

shouldnt it only get called once?

am i missing something?

i am confused

would be awsome if anyone had any hints for me

#1
05/03/2007 (9:38 am)
Odd numbers make the trigger fire, even numbers make it stop. When any key is pressed, it calls that function twice, once for the key going down and once for the key going up. "$mvTriggerCount0++" needs to be incremented twice, try making a function like this:
function mouseFire()
{
   $mvTriggerCount0++;
}
And call this function when your key is pressed.

Hope this makes some sense.
#2
05/03/2007 (10:20 am)
You also want to check your weapon's script state machine to make sure that there is a transition out of the fire state--it's possible that you never leave the fire state, giving you a continuously firing weapon.