Page 1 of 1

Pausa nos tiros

PostPosted: Tue Jan 03, 2012 5:00 pm
by luizluizhenriqu
Hi! I'm creating a shooter game, so far so good I can make the basic weapons such as pistols and shoot machine guns and shotguns and plan to put automatic weapons lesers not here comes the problem can not I make a pause time between one shot and other, already tried everything and tired to create time and I am newbie! please help me!

Re: Pausa nos tiros

PostPosted: Tue Jan 03, 2012 6:58 pm
by skydereign
Well, you can use a variable to create a pause in between the shots fired. So you'll need to declare a variable, in this case I'll call it bullet_timer. If you don't know how to declare a variable, the easiest way is to go to global code and add this script.
Global Code
Code: Select all
int bullet_timer;

int is the variable type (meaning it only stores integer values) and bullet_timer is the name of the variable. Anyway, if you have space as your shooting event, you can do something like this.
player -> Key Down Space (repeat enabled) -> Script Editor
Code: Select all
bullet_timer++;
if(bullet_timer>=2)
{
    // replace this line with your CreateActor bullet function call
    bullet_timer=0;
}

This will make the player fire a bullet every other frame. You can increase the 2 to decrease the frequency of bullet fire.