0 Favourites

How do I Change fire rate of bullets

  • Sorry, im a bit newbie and i just came out of the first beginner tutorial.

    And my question is to how to change the fire rate of the bullet spawn.

    So that they For example, shot one, and than wait 1 sec, and than shot 1 and wait 1 sec etc. etc.

    It didnt worked the way i did haha.

    Thanks, i would apreciate if you try to be a bit precise on how to do it.

    Thank you

  • What you are currently doing is, when the mouse is clicked, wait 1 second and fire the bullet.

    What I think you want to be doing is, every X seconds, is left mouse button down -> fire bullet.

  • What you are currently doing is, when the mouse is clicked, wait 1 second and fire the bullet.

    What I think you want to be doing is, every X seconds, is left mouse button down -> fire bullet.

    ¿How would be going that event you say?

  • Hi,

    You can add boolean var to Jugador (Asreload= true (default))

    condition: on mouse leftclick AND Jugador Asreload=true

    action : set Jugador boolean var = false

    Jugador spawn bullet

    wait "reloadtime" (variable,1sec,10sec what you want...)

    set jugador bolean var= true

    well done

    EDIT: you can change condition "on left click" by "on left mouse down"

  • So create an event using the "every X seconds" event. Then add a condition of "mouse button is down", and then use the same action for firing.

  • So create an event using the "every X seconds" event. Then add a condition of "mouse button is down", and then use the same action for firing.

    Sorry for disturbing you bro but i cant find "Every X Seconds" in the event/action area.

    ¿Shall i create a new object for that? Or could you send me a screen shot on how the formula is?

    Thanks

  • every x second is under system events.. the cog wheel icon. It has to be a primary or secondary event, you won't find it under actions or not primary/secondary events.

    I think from your post what your actually wanting is for the player to fire a single bullet by clicking and have to reclick for each shot... however you don't want them to be able to do it quicker than once per second... ?

    If that is the case you will want to use a Boolean instance variable on your player, lets call it "hasFired=false". Now move your current Wait-1 to beneath the fire bullet action and add an action "hasFired=true" before it and a hasFired=false after the Wait.

    On mouse click fire bullet

    hasFired=true

    Wait 1 second

    hasFired=false

    Add a second condition to Mouse click fire bullet (right click on,above or below the little green arrow on left side of condition space and select add-new condition)

    that condition will be hasFired=false.

    Now when the game starts the player can shoot by pressing mouse button because "hasFired" is false by default but once they click button and fire a bullet the flag hasFired will show true and clicking will not do anything but once a second passes it will work again because hasFired will again be false.

  • If you want the mouse to be held down then you would imput

    Mouse: Mousebutton (Left) is down

    System: Every (0.25) Seconds

    Jugador: Create object Bullet Layer 1 Image point 1 (Both system and jugador in same action sequence)

    That should work

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Hey everybody I'm having the same problem with the bullets I followed step by step what chrisinfinger wrote but I'm having difficulties finding this :

    Add a second condition to Mouse click fire bullet (right click on, above or below the little green arrow on left side of condition space and select add-new condition)

    that condition will be hasFired=false.

    Is it me or there is something wrong?

  • Thanks all of you for helping me !

    I apreciate your help, this comunity is amazing

  • [quote:5aogo2ct]Hey everybody I'm having the same problem with the bullets I followed step by step what chrisinfinger wrote but I'm having difficulties finding this :

    Add a second condition to Mouse click fire bullet (right click on, above or below the little green arrow on left side of condition space and select add-new condition)

    that condition will be hasFired=false.

    Is it me or there is something wrong?

    What the part in parenthesis is explaining is how to add a second condition to an existing condition, you right click where the tiny arrow is to the left of the first condition but still inside the condition box and the drop down window will easily allow you to add another condition to the existing one... you could also just make another and drag-drop it inside first one, or several other ways...

    The hasFired=false is a variable you made (it could be named anything) you add it to condition using System-compare variable for globals or Sprite-compare instance variable for instance variables.

  • Alright so when i go sprite - compare instance variable.. it says < none add an instance variable first> but i added the hasfired = false to my sprite... why isnt it showing up here?

    really feel like im missing something here.. i got the rest in there

    On mouse click fire bullet

    hasFired=true

    Wait 1 second

    hasFired=false

    but adding this sprite - compre instance variable i cant choose hasfired..

    so number and text instance variables do show up but not boolean.. is this a bug?

  • whatever i figured it out.

    it would be nice if people would post the solutions they discover that actually work by saying such and such solution worked for me.. or even better just take a screenshot quickly for heavensake or write it out even. That way when someone runs into the same problem you had and needs help they can actually learn something too!

    anyways here is what i did:

    Make an instance variable for your player sprite. Do this by clicking the sprite image and going to over properties find Instance variables add/edit and create that sucker.. i named mine bulletdelay _but you can name it anything_ and under type change it to boolean and then set the initial value to true.

    Events/Conditions:

    mouse - on left clicked

    playersprite - is boolean instance variable set - bulletdelay

    Actions:

    playersprite - set bulletdelay to true

    playersprite - spawn (bullet)

    playersprite - set bulletdelay to false

    system - wait x seconds

    playersprite - set bulletdelay to true

  • Here's how I'd do this. You can make the fire-rate an instance variable on the player if you want but I just threw this together in 5 minutes.

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