Author Topic: How to delay a fire?  (Read 1015 times)

How do you make a delay when you are clicking a mousebutton on something?

Like for example, if you press your LMB to fire a default BL gun, 3 seconds later, it shoots.


Increase one of the times in the weapon states.

Increase one of the times in the weapon states.

Thanks, but where do I find that?

On the function OnFire or is it a projectile thing?

Code: [Select]
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.5;
stateTransitionOnTimeout[0] = "Ready";

stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "Wait";

stateName[2] = "Wait";
stateTimeoutValue[2] = 1.2;
stateTransitionOnTimeout[2] = "Fire";

stateName[3] = "Fire";
stateFire[3] = true;
stateTimeoutValue[3] = 0.5;
stateTransitionOnTimeout[3] = "Ready";

you'd do something like this


If you do create a special onFire function make sure you create timeouts using getSimTime() (or something like that) and then subtract the time based on how long you want it to be. (Prevents people from doing rapid fire switching)

Example:
function ShotgunImage::onFire(%image, %obj, %slot)
{
   if(getSimTime() - %obj.lastFire[%image] < 3000) //less than 3 seconds
      return; //Prevent them from firing

   %obj.lastFire[%image] = getSimTime();
   //Spreadshell code
}
« Last Edit: September 06, 2016, 06:09:46 PM by Kyuande »