How do I: wait time before next shot

0 favourites
  • 10 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • Greetings,

    at first im sorry if i didnt searched probably for the right topic i need, because i actually dont know what to search for.

    so my question is: i set my fire button to the left mouse button and its working just fine, but i dont want to abuse it so i can shoot like 10 bullets in a second. How can set it up to shoot like, lets say 1 bullet every 1 second.


  • While pressing left button > every 0.1s > spawn bullet

    You can find in the system the expression "Every X seconds".

  • Thx for the fast respond, that helps alot but actually i wanted to shoot one bullet every 1 second even if i smash the mouse button, just asked the wrong way :S holding the left mousebutton to shoot isnt a option for me. Im sorry for the trouble

  • You can use any trigger you want. You don't need to stick with the "While pressing left button". Also, if you want 1 shot per sec just adjust it using "Every 1 sec" > Spawn bullet

  • ye i know but thats the point.

    its like this now:

    mouse > on left button clicked -> "player" spawn "bullet" on layer 0 (image point1) // but now i can shoot as much as i want. it should take up to 1 sec before i can shoot the next bullet even with pressing the mouse shortly after. again, im so sorry for the trouble and the waste of time

    maybe im to stupid to see the right trigger to use but i cant find a way to solve this problem on my own :<

  • Make an instance variable called cooldown.

    On left button clicked and if cooldown = 0 -> fire bullet and set cooldown to 1

    If cooldown is greater then 0 -> subtract 0.5 every 0.5 seconds

    You can change the numbers to suit your needs.

  • ok i guess i got it so far but one more question pls, how do i trigger those 0.5 seconds ?

    atm its like this for me:

    1. "bullet" cooldown > 0 -> "bullet" subtract 0.5 from "cooldown"

    2. "mouse" on left button clicked -> "player" start animation from beginning

    "bullet" cooldown=0 "player" spawn "bullet" on layer 0 (image point1)

    "bullet" set cooldown to 1

    i hope there is not a "and" command like the "or" one, since i cant find it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can right click in the trigger area and click on Add Another Condition. That's the same as saying "And". There is another option in there to "Make an OR block". That's the same as saying "Or" but it's a bit more complicated. You just need to use and so just add another condition along with on left button clicked.

  • I give my player an instance variable that acts as a condition to shooting. On shooting, set the variable Player.TimeNextShot to time + 0.5 (or whatever). Then, as a condition to a player shoot demand, check to see if Player.TimeNextShot < time. I find it allows for easy variation in the delay time, depending on weapon in use etc.

  • wow guys im so stupid, i didnt even tell that script what to do if the value reaches 1, exept for subtract something from it every XX seconds -.- im really really sorry for wasting all of your time

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