[SOLVED] *Edited W/ capx* How do I Pause Turret Rate Of Fire

0 favourites
  • 11 posts
From the Asset Store
Create your own wss server and ws server with ssl and without ssl.
  • If I have 5 different turrets on 1 layout, how do i get each turret to have a different fire rate?

    i.e: Pause each different Turret from firing

    TURRET 1 shoots every 1/2 second, fires 3 times then waits 1/2 second

    TURRET 2 shoots every 1 second, fires 5 times then waits 1 second.

    So on & so on.

    I've been trying for a few days to get this to work. I can get the turrets to fire at different rates but the problems I'm having is:

    1) The Turrets rotate toward player even with a Rotate disabled action.

    2) I can't get the turrets to pause their firing individually since they are controlled by events/actions.

    I was thinking i may have to add instance variables to each turret, but i don't know enough about variables to implement this logic. Even after reading tutorials/ manual and posts on the subject.

    Can anyone help with this dilemma? This is the last of my major hurdles for the game mechanics.

  • Well, it's really hard to give exact advice without seeing how you have your logic structured.

    That being said, using instance variables to pick thru instances is probably the way to go. Also, if you store a turrets state (enabled/disabled) in an instance boolean, it helps de-couple your logic from the turret behavior itself, which can be helpful.

    Do you have multiple turret objects? Or do you have a modal turret object that can work different ways (fire rates, health, etc.)?

    If you could share a capx, that would help. If you don't feel comfortable posting one, you could strip it down as much as possible, or PM me if you want.

  • Hey TiAm

    Thanks for the reply

    Yes, there will be 4 - turrets per layout(lvl). I have them firing but they each fire at the same rate. I think i seen a tutorial that uses variables with a reverse heath meter( timer).

    I'll post a capx when i get home.

  • If you could share a capx.

    Here you go TiAm

    https://www.dropbox.com/s/izlic9yaklgmrlm/Turret1.capx?dl=0

    The capx has been edited. Still trying to figure things out.

    Again, thanks for any help you may give.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Whew, that was more difficult than I thought it would be. Mostly because of my own stupidity of course... <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    Anyway, pretty sure this is what you wanted to do. Capx:

    https://www.dropbox.com/s/5x3vu7tn2vwuc ... .capx?dl=0

  • Whew, that was more difficult than I thought it would be.

    I know, right! I was stuck on this for 5 days.

    The extra spears were added with the corresponding tubes, but i deleted the tubes trying to get it to work & forgot to delete the spears.

    I'm gonna have to take a couple days and go over your logic, to get a better understanding of C2 & how things work.

    Anyways, thanks I love what/how you implemented that. That's awesomesauce right there, I am voting for you for user of the year!

    @TiAm for User Of The Year!

    Also, what is Tmod?

  • Tmod just means indicates what parts are code I've added.

    Glad I could help.

  • Hey TiAm just saw your Tmod note: "Also, spears have bullet and solid. Why?"

    If object has "bullet" behavior it doesn't need "solid"?

    AND

    "Tmod: You only need 1 spear tube object. I left SpearTube2 in the project, but frankly, I see no reason for it's existance."

    As you may have noticed spears appear to fire from tube 1 and into tube 2. If I clone tube 1 and use this as tube 2, that tube would have all the behaviors/ variables as tube 1 wouldn't it?

    So i thought it easier to have that extra object, instead of going through and removing the behaviors/ instances from tube 2.

  • Hey TiAm just saw your Tmod note: "Also, spears have bullet and solid. Why?"

    If object has "bullet" behavior it doesn't need "solid"?

    Generally, it doesn't. You don't need solid to register or test for collisions. I don't see any reason why your spears need it. It's disabled by default in my capx. Here's the manual entry on solid; it might give you a better idea of what it's good for:

    https://www.scirra.com/manual/104/solid

    "Tmod: You only need 1 spear tube object. I left SpearTube2 in the project, but frankly, I see no reason for it's existance."

    As you may have noticed spears appear to fire from tube 1 and into tube 2. If I clone tube 1 and use this as tube 2, that tube would have all the behaviors/ variables as tube 1 wouldn't it?

    So i thought it easier to have that extra object, instead of going through and removing the behaviors/ instances from tube 2.

    Ah, I see. I didn't realize that was an intended function. In that case, go ahead and use it. Maybe give it a slightly different name so you know what it's supposed to do (SpearCatcher?).

    Actually, if spear tubes always have a corresponding spear catcher, you could disable my logic that tests for arrows overlapping Bloks and TiledBG_Bloks, and move the actions there to 'On Collision with SpearCatcher'.

  • Hey TiAm how could i reset the variable(s) timers to their initial state if the player moves off a detector?

    Right now if the player moves off of a detector the speartube stops firing but if the player quickly moves back on to the detector the speartube fires the remaining spears (1 or 2) as if the firing state has only been paused.

  • Here, this capx. Look for the new event 'player: on collision with detector':

    https://www.dropbox.com/s/ebohsal011qoq ... .capx?dl=0

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