Pick, for each ??

0 favourites
  • 4 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • 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 :

    [attachment=0:ws4yi4mq][/attachment:ws4yi4mq]

    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

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also the important thing is the condition before the first for each to be sure this part of code won't be executed continuously

  • Thanks for the answer.

    I finally made another method : I apply the bonus at the creation of the turret/turretBonus.

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