Make a weapon wait time after shooting.

0 favourites
  • 7 posts
From the Asset Store
Add calm and a lounge vibe to your games with these 8 tracks
  • I am making a zombie survival platform game, but I have run into a problem where if the player shoots (X), I can repeatedly tap X and a stream of bullets will come out.

    Is there an easy way to set a small wait time after each press of X so you cant send out so many? Also, I would like to do the same for a reload time. I have tried to add the wait command to the end of my events but it won't work. <img src="smileys/smiley11.gif" border="0" align="middle" />

    I hope to get an easy solution to this!

  • how big is the wait command?

    maybe you could limit it by limiting how many bullets are on screen.

  • There are many threads on timers. Have a search.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The wait command is one way, or you could add a timer to your player, which increases/decreases each tick/every x seconds or whatever, and then you can only shoot when the timer has reached a certain value. E.G

    Every tick : Player.ShootTimer - 1

    On key press :

    Player.ShootTimer <=0 : Shoot

                          : Set Player.ShootTimer to 30

    That's a coding approach, but the wait command should do the trick anyway.

  • Maybe this? What it does is destroy a bullet in flight as soon as the key is pressed but immediately creates one. The created one will stay on the screen until it leaves the layout or the key is pressed.

    On key pressed-destroy bullet

                  -Create bullet

                  -set Speed & direction here

  • Hello gamingwithpi,

    add a variable to your player that holds the timespan until the next round can be fired. Then in a system event check if time is greater than the time that is stored in your variable. Right after shooting, add the amount of time you wish to wait for the next round to the current time.

    if system->time > Player.timeToShoot

    --> Player-> spawn Bullet

    --> Player set timeToShoot to: time + amount_of_time_to_wait

    time is the system expression.

    Hope this helps.

  • Thanks everyone... I will be trying this out (sorry for the late reply i was on vacation)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)