Killing units made by triggers in specified region.

PapaRoach

New Member
Reaction score
0
I'm having an issue where after i spawn 3 zerglings within a region named "battlefield" I am unable to kill them.

I have no idea how to go about this. From what I know, units spawned with triggers are read only and make it impossible to add them to a unit group. Thus, all of the ways I know of getting rid of multiple units are void. The only way I can think of doing it is assigning each created unit to a variable after it has been spawned and then kill them by referencing the variable. This seems a little excessive though. I'm hoping someone can tell me an easier way.
 

Severon

New Member
Reaction score
7
Its is possible to add those units to a unit group.

Trigger:
  • Events
    • Timer - Periodic Timer 5.00 Seconds Game Time
    • Local Variables
      • Unit Group - AllUnitsInMeWillDie
    • Conditions
    • Actions
      • unit - Create 3 Zerglings for Player 1 at Starting Location 001
      • set AllUnitsInMeWillDie == (last created units)
      • wait 5.00 seconds game time
      • kill!


granted you might want to make that unit group global so that another trigger can use it

EDIT:
Trigger:
  • Events
    • Timer - Periodic Timer 5.00 Seconds Game Time
    • Local Variables
      • Unit Group - AllUnitsInMeWillDie
    • Conditions
    • Actions
      • unit - Create 3 Zerglings for Player 1 at Starting Location 001
      • Unit Group- add (last created Units) to AllUnitsInMeWillDie
      • wait 5.00 seconds game time
      • kill!


This one might work better. :)
 

Cheekything

TH.net Regular
Reaction score
5
Note using the above it doesn't check if they are in the region still.

Personally I'd suggest you create an array of units created and when they are created add them to the array, this way you can find the counter for the array and kill the last 3 much easier and without using Unit Groups.

It would be a bit more code to trigger but it would be more adaptable for later on.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top