Been a while since I triggered but here is generally how I'd do it.
[
Trigger: Map initialization.
Actions-
Set variable (real) SpawnTimer = 0.5 (How fast you want the individual units to spawn)
Set variable (integer) SpawnCount = 30 (How many units you want to spawn per wave)
Set variable (integer) SpawnedUnits = 0 (How many units have spawned so far)
]
[
Trigger: Spawn Unit (Initially Off)
Event-
Periodic timer every (int(SpawnTimer)) seconds (Once turned on this trigger will run every 0.5 seconds)
Actions-
If Then Else - Multiple Actions
If-
SpawnCount <- SpawnedUnits (If the number of spawned units is less than the number of units we need to spawn)
Then-
Create Unit - 1 'WaveUnitType' at spawnpoint facing whatever direction (Create a unit)
Set SpawnedUnits =+ 1 (Add one to number of spawned units variable)
Else-
Trigger - Turn off this trigger. (If we created all 30 of our units turn off this trigger to stop spawning units)
]
[
Trigger: Level 1
Event- Whatever starts spawning units
Actions-
Set WaveUnitType = "Marine"
Set SpawnedUnits = 0 (Reset the number of units spawned to 0 if you're doing more than 1 level)
Set SpawnCount = 30 (You can change how many units spawn for each level, say you want 15 bc instead of 30 marines for level 2)
Set SpawnTimer = 0.5 (You can also change the spawn timer here to spawn units slower or faster depending on what level you're on)
UI - Display Message 'Level 1 - ' + String(Unit Type(Name of WaveUnitType)) (Display to the player what level it is)
Trigger - Turn On Spawn Unit (Turn on the unit spawning trigger)
]
If you'd like I can show you a cleaner (but more confusing) way to do this in a couple hours via a skype or twitch stream. But due to it being more complex I didn't even want to attempt explaining it with limited resources at work. With HotS release I've been thinking about getting back into Galaxy Editor, and would help you with your project whatever it may be until I come up with something for myself to work on.
I'm no professional but I've made a fully functional TD before with leaderboards and dialogs and income and lots of TD stuff. :)
Basically, if you want to spawn them periodically you'll need to do "repeat X times + spawn 1 unit of type Y at location Z + give order to move + wait 1 second" instead of using directly "spawn X units of type Y at location Z + give order to move". You'll need several variables to do this, if your triggers are well done you'll only need 1 trigger to spawn any wave and give them their orders.
Some of the variables should include: enemies count, enemies type, spawn location, target location, waiting time between waves (not necessary but some people like to include a variable delay between waves, rather than waiting for the wave to be killed), waiting time between units spawning (some enemies being faster than others, it's an interesting variable to change to prevent massive unstoppable/unbalanced waves to ruin your map).
I'm making a tower defense and my waves spawn all of the units in the wave at once. How do I make it spawn one at a time like it should?
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
Been a while since I triggered but here is generally how I'd do it.
[
Trigger: Map initialization.
Actions-
Set variable (real) SpawnTimer = 0.5 (How fast you want the individual units to spawn)
Set variable (integer) SpawnCount = 30 (How many units you want to spawn per wave)
Set variable (integer) SpawnedUnits = 0 (How many units have spawned so far)
]
[
Trigger: Spawn Unit (Initially Off)
Event-
Periodic timer every (int(SpawnTimer)) seconds (Once turned on this trigger will run every 0.5 seconds)
Actions-
If Then Else - Multiple Actions
If-
SpawnCount <- SpawnedUnits (If the number of spawned units is less than the number of units we need to spawn)
Then-
Create Unit - 1 'WaveUnitType' at spawnpoint facing whatever direction (Create a unit)
Set SpawnedUnits =+ 1 (Add one to number of spawned units variable)
Else-
Trigger - Turn off this trigger. (If we created all 30 of our units turn off this trigger to stop spawning units)
]
[
Trigger: Level 1
Event- Whatever starts spawning units
Actions-
Set WaveUnitType = "Marine"
Set SpawnedUnits = 0 (Reset the number of units spawned to 0 if you're doing more than 1 level)
Set SpawnCount = 30 (You can change how many units spawn for each level, say you want 15 bc instead of 30 marines for level 2)
Set SpawnTimer = 0.5 (You can also change the spawn timer here to spawn units slower or faster depending on what level you're on)
UI - Display Message 'Level 1 - ' + String(Unit Type(Name of WaveUnitType)) (Display to the player what level it is)
Trigger - Turn On Spawn Unit (Turn on the unit spawning trigger)
]
@Ragesapien: Go
Alright. That sounds like it should work, but it might be tedious to do for every wave. But I guess that's what I have to do.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
If you'd like I can show you a cleaner (but more confusing) way to do this in a couple hours via a skype or twitch stream. But due to it being more complex I didn't even want to attempt explaining it with limited resources at work. With HotS release I've been thinking about getting back into Galaxy Editor, and would help you with your project whatever it may be until I come up with something for myself to work on.
I'm no professional but I've made a fully functional TD before with leaderboards and dialogs and income and lots of TD stuff. :)
Let me know.
Basically, if you want to spawn them periodically you'll need to do "repeat X times + spawn 1 unit of type Y at location Z + give order to move + wait 1 second" instead of using directly "spawn X units of type Y at location Z + give order to move". You'll need several variables to do this, if your triggers are well done you'll only need 1 trigger to spawn any wave and give them their orders.
Some of the variables should include: enemies count, enemies type, spawn location, target location, waiting time between waves (not necessary but some people like to include a variable delay between waves, rather than waiting for the wave to be killed), waiting time between units spawning (some enemies being faster than others, it's an interesting variable to change to prevent massive unstoppable/unbalanced waves to ruin your map).