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

Get help using Construct 2

Post » Sat Dec 13, 2014 7:31 pm

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.
Last edited by jeffige on Sun Dec 14, 2014 7:53 am, edited 3 times in total.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sat Dec 13, 2014 9:43 pm

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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Sat Dec 13, 2014 11:09 pm

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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Dec 14, 2014 2:09 am

TiAm wrote:
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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Dec 14, 2014 6:37 am

Whew, that was more difficult than I thought it would be. Mostly because of my own stupidity of course... :mrgreen:

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

https://www.dropbox.com/s/5x3vu7tn2vwuc ... .capx?dl=0
You do not have the required permissions to view the files attached to this post.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Sun Dec 14, 2014 7:52 am

TiAm wrote: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 @TiAm. 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?
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Dec 14, 2014 9:10 am

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

Glad I could help.

:)
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Sun Dec 14, 2014 5:42 pm

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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Dec 14, 2014 8:23 pm

jeffige wrote: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

jeffige wrote:"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'.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Wed Dec 17, 2014 6:44 pm

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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Next

Return to How do I....?

Who is online

Users browsing this forum: digitalsoapbox, el3um4s, RetrocadeMedia and 1 guest