fixed turrets

Get help using Construct 2

Post » Mon Sep 23, 2013 2:55 pm

hi all.

i added some turret in my game.
some are working fine.

but i have one kind of turret i cant code properly
since my method dont work, maybe someone have an idea.

these turret goes by group.

if one turret of "group 1" have line of sight on the player, all turret of "group 1" shoot.
they shoot straight, dont need to target the player.

i want add an instance variable called shoottimer, where i can enter the rate of fire of this particular turret.

some will shoot every 1 sec, some every 0.5, some every 2, etc.
and i need to tell each turret which rate of fire it will be.

and when no turret of "group 1" see the player, they all stop firing
(but turret of "group2" may fire)

i cant make it work ! someone could help ?
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Mon Sep 23, 2013 4:18 pm

your capx would help solve your problem.
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Post » Mon Sep 23, 2013 4:24 pm

yep please provide .capx so we can locate the problem. also, which bit of the functionality you listed is not working?
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Mon Sep 23, 2013 10:10 pm

ok my capx was very large with many more thing so it would be a bit confusing.
i made a clean and simple version with only this problem.
maybe it will help.
let me know if you have some ideas !
thanks for your help .


here is the capx :
https://www.dropbox.com/s/euk17lh5c6scqk6/testsidegun.capx
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Sep 24, 2013 10:22 am

@plinkie
@yonda

capX available
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Sep 24, 2013 6:59 pm

set a group for each speed that should work fine
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Post » Tue Sep 24, 2013 7:20 pm

Just change timershoot to different values to set the firerate. You've pretty much already done it.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Tue Sep 24, 2013 8:46 pm

@plinkie
@yonda


but it doesnt work. i must miss something in the use of for each.
all turret fire at the same rate, even if timershoot is different on each turret.
thats why im asking.
please, if it seems obvious to you, could you make a capx to show me how it must be done?
B
19
S
5
Posts: 104
Reputation: 1,761

Post » Tue Sep 24, 2013 9:55 pm

It is because all of the turrets are clones so when you edit the instance variable it edits it for all turrets. You need to have separate objects really. You can do something tricky with UIDs too but I've not really looked into that.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Tue Sep 24, 2013 9:59 pm

jep use seperate turrets. put them into a family.
B
18
S
6
G
3
Posts: 197
Reputation: 4,129

Next

Return to How do I....?

Who is online

Users browsing this forum: Ryan Kocourek and 13 guests