Lock a turret target using UID so a large group of turrets only fire at unlocked targets

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Unlock Levels, Worlds & skin plus add coins by watching ads
  • How would you go about having a player or enemy turret target only it's target without the other turrets in a large group or more than one, would not fire on the same target, but would continue searching for another unlocked turret target.

    When I move my tanks in groups of more than one it is common that more than one will reach the range at the same time with a shot from each turret on the same target. My enemies are on patrol and usually when my level begins they are grouped tight at some starts but not always due to the random settings. It just looks bad to have 3 or more rounds wasted on one target that dies with 1 hit. It also hurts the ammo count in the end.

    I am guessing using an array that holds the UID of all turrets and locking one element by the first in range, having the other turrets continue their targeting etc ? I just haven't experimented with using arrays for such as this.

    This is a large desktop level that uses Trees as cover and they are randomly placed every new level start. Depending on what the level gives you sometimes I have pretty large areas that does not have any cover. Moving my Tanks can be 1 to 14 so having some order in targeting would be helpful.

    Any advice would be greatly appreciated Thanks..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use automatic targeting - don’t add entire objects as targets. Instead, use the 'Acquire target' action for each turret/target.

    You can track targets in an array, but I’d suggest using instance variables instead. For example, a NumberOfAttackers variable on a tank could store how many turrets are currently firing at it.

    When picking a new target for a turret, look for tanks in range with the lowest NumberOfAttackers value.

    Check out this example on how to use 'Acquire target':

    howtoconstructdemos.com/how-to-limit-the-angle-of-view-for-turret-behavior

  • Thank you for the information and suggestions. I will start sorting this out with instance values and non objects. I have a 14 / 14 Battle with a surprise on the 3rd difficulty tier of 10 more enemy randomly spawned and patrolling. 3 difficulty levels of wimp, getfroggie, and hard. Each tier has land mines unseen by player and enemy not effected. Each of 5 levels or game starts is tallied on the final 5th to give a winner score. 30 minutes of fuel for all ending on empty and scores are posted and next level shown on menu along with the highscores for each level. Adding as I continue building the game. Since all the Tanks are under cover when under a tree or group of trees I have locators top center of each turret which can be on or off for player but always on for enemies. The game never plays exactly the same every time you start just by using the random tree placement on each start. Same with the 10 extra enemies at the HARD level. I get caught up playing more than adding the things I plan on. heh It's like a chess game but surprisingly the enemy is always pretty close to winning and winner totals is always 14 plus the extra 10 if on HARD.

    Thank you

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