How do I make automatic reloading!

Get help using Construct 2

Post » Wed Mar 18, 2015 6:08 am

I'm using turret behavior with a machine gun that acquires an object when i click it, rotate to it and fire.
now I'm trying to make an automatic reload system that reloads a new bullet every 2 secs but not while the machine gun is shooting (no shooting and reloading at the same time, reloading should begin after 2 secs from stop shooting)
i can't find a condition (is shooting) that makes the condition true while shooting, instead there is (on shoot) condition and triggered once. so i tried using the condition (if bullet is on screen) as a work around.
i tried (every 2 secs + bullet isn't on screen ----> add 1 to ammo) but reloading starts immediately after stop shooting and continue every 2 secs or may be something else is wrong about timing.
how can i solve this ?
Hope I explained my problem correctly but to give a clear example for what i mean : "Swamp attack" reloading system :)
Thank you.
B
15
S
5
Posts: 192
Reputation: 1,514

Post » Wed Mar 18, 2015 6:22 am

Perhaps you could use a timer? Whenever you shoot, reset the timer. If the timer ever finishes, that means that you have stopped shooting.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Wed Mar 18, 2015 10:13 am

I've to set the value of this timer, what value should i use ? how many secs ?
B
15
S
5
Posts: 192
Reputation: 1,514

Post » Wed Mar 18, 2015 4:48 pm

I would make a timer like this first; It counts from 2 to 0 and when it hits 0 it returns to 2 again and so on.

Then, I would give a value to turret or I would use a global variable.

Then;

1- When timer hits 0

2- Animation is not playing shoot
OR
I'd prefer "not at shoot stance" (like when it's at 1 turret can shoot, when it's at 0 turret can't shoot)
B
22
S
5
G
2
Posts: 210
Reputation: 3,382

Post » Wed Mar 18, 2015 4:55 pm

Well, you said
reloading should begin after 2 secs from stop shooting
so I think 2 seconds would be a good starting point. You might add in a little extra time, to be sure that the target has been lost.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Wed Mar 18, 2015 9:29 pm

I'll give it a try, thanks for help :)
B
15
S
5
Posts: 192
Reputation: 1,514


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 34 guests