How do I make turrets shoot only targets in front of it

0 favourites
  • 7 posts
From the Asset Store
50 front view of buildings JPG - residences shops and offices - 2048x2048
  • Hi, please look at attached capx. Its just an example of tower defence that I found here on the forum. I made some changes to it.

    The problem is that the turrets with a long range and rotation will target the nearest or first in range targets which is not good for my game. I want to make turrets shoot only targets in front of it but not from the other spawner or line. Ofc, I can disable rotation but It will limit tower places.

    Also, I found interesting thing during experimentations. If disable rotation and place turrets only in front of the spawners they will shoot their targets by targets positioning (both for nearest and first in range options). If the targets is on the same distance to the towers they will shot simultaneously. But if the front target is farther than the target of the upper or lower turret it won't shoot till the closest target will be destroyed. It is clearly seen if you place 1 tower in front of each spawner and play till wave 2 or 3.

    I just want make turrets from each line shoot targets from their own spawner. Is that possible rather than making enemy clones for each spawner and checking where turrets were placed and programming them to shoot targets from their line? Huh. Thanks.

  • Click on ArrowTurret, and change the following properties

    Rotate - Yes

    Target Mode - Nearest

  • Click on ArrowTurret, and change the following properties

    Rotate - Yes

    Target Mode - Nearest

    If I do so, then turrets will shoot at targets from other lines which is not acceptable for me.

  • You could give each target a Variable, and have turrets that are in the middle, shoot only targets that have the variable Middle.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could give each target a Variable, and have turrets that are in the middle, shoot only targets that have the variable Middle.

    Sounds great, but in practice I've got troubles.

    I can give variables to targets, but how make turrets target only enemies with that variable?

  • Code's a bit longer, and goes down a few levels, but it does the job. Reason it's set out this way, is because if you move the action of line 31 to line 29, it freaks out, because it doesn't know which Enemy to target when they are the same distance from the ArrowTower.

    I also removed a few unnecessary lines of code, and a few duplicate sprites, and am now using instance (very handy <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> )

    https://dl.dropboxusercontent.com/u/108 ... iming.capx

  • Code's a bit longer, and goes down a few levels, but it does the job. Reason it's set out this way, is because if you move the action of line 31 to line 29, it freaks out, because it doesn't know which Enemy to target when they are the same distance from the ArrowTower.

    I also removed a few unnecessary lines of code, and a few duplicate sprites, and am now using instance (very handy )

    Wow, thanks!

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