Pick, for each ??

Get help using Construct 2

Post » Fri Mar 13, 2015 1:12 pm

Hello

Here's the context : I'm making a tower defense. For that, I create 2 families : Turrets and TurretBonus.
Turrets are classical turrets with the behavior turret.
TurretBonus don't have this behavior, their goal is to increase capacities of turrets in their range. Ex : add 50% to the turret range.

I tried this code :
turretBonus.png


With 1 turretBonus and 1 turret in the range of the bonus, no problem.
But with 2 turretBonus : range increases indefinitely
With 1 turretBonus and 2 turrets in the bonus range : idem..

Any idea ?

Thanks
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 45
Reputation: 509

Post » Fri Mar 13, 2015 2:51 pm

Hi,

I would do :

For each Turrets
- Pick Nearest turretRange to (Turrets.X,Turrets.Y)
-- For each TurretsBonus
---TurretsBonus is Overlapping turretRange -------------> set Turrets range to Turrets.Turret.Range *1.5
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Fri Mar 13, 2015 2:54 pm

Also the important thing is the condition before the first for each to be sure this part of code won't be executed continuously
B
14
S
4
G
2
Posts: 190
Reputation: 3,938

Post » Sun Mar 15, 2015 5:45 pm

Thanks for the answer.

I finally made another method : I apply the bonus at the creation of the turret/turretBonus.
B
6
S
1
Posts: 45
Reputation: 509


Return to How do I....?

Who is online

Users browsing this forum: imothep85 and 1 guest