I took a few days off to clear my head. Before diving into Unity I decided to examine the combat gif (a few posts back) with fresh eyes. I couldn't help but feel it was missing the mark. Mostly I couldn't tell which units in a squad were being useful and which were generally useless schmucks...
who is doing what and why
One of my design goals is to make you (the player) care about the individual units (for reasons I'll examine later on). I don't plan on letting you have more than four at a time. I want you to name them, grow them, love them and other awkward things too.
But if nothing else I want you to know that they are doing their job and any effort you spend on their improvement offers clear and visible feedback.
one at a time, please
Having every unit in a squad fire the moment it is ready is clearly problematic. More often than not they all fire at once. It's difficult to see which shots hit and which missed. Also difficult is who actually fired. I needed to slow things down.
So now squads have a StaggeredFireScheduler
component. Essentially it's a bit of logic that tracks each unit in a squad and let's them fire as soon as their ready and as soon as the squad is ready. Then it de-prioritizes that unit and repeats.
More specifically this is the pseudocode
// create a list of all the units in a squad ordered by priority
// for now that priority is arbitrary
prioritizedUnitList = prioritized list of units in squad
// create a cooldown that is inserted between unit shots
squadCooldown = .5 seconds
// Per Frame
if squadCooldown is not finished
return;
for unit in prioritizedUnitList
if unit is readyToFire
unit->fire() // shoot
unit->deprioritize() // move priority to end of list
squadCooldown->reset() // start the squad cooldown
break;
The result is:
- Unit A cooldown finishes
- Unit A shoots. Sent to back of list. Resets squad cooldown.
- Squad waits .5 seconds
- Unit B cooldown finishes
- Unit B shoots. Sent to back of list. Resets squad cooldown.
But what if Unit A has a much faster fire rate than Unit B? Well the priority system ensures that units that just fired are less important that units than haven't fired in a while. It would look like this:
- Unit A cooldown finishes
- Unit A shoots. Sent to back of list. Resets squad cooldown.
- Unit A cooldown finishes
- Squad waits .5 seconds
- Scheduler checks the list in order: B=>not ready. A=>ready
- Unit A shoots. Sent to back of list. Resets squad cooldown.
- Unit A cooldown finishes
- Unit B cooldown finishes
- Squad waits .5 seconds
- Scheduler checks the list in order: B=>Ready. A=>not checked
- Unit B shoots. Sent to back of list. Resets squad cooldown.
again, the point is clarity
The point is to slow down the action enough to see the efficacy of each individual unit so that you (the player) can collect meaningful feedback and make informed decisions.
Furthermore these units you control must not be faceless entities but distinct individuals whose successes and failures are emotionally impactful.