The big change was adding humanoid enemies that take cover. Finding cover was adapted from a very useful post on the Unity forums, which uses the following flow:
- Sample random (or not-so-random) positions around the unit’s current position
- For each sample position, find the nearest edge in the NavMesh.
- Obtain the normal field of the resulting NavMeshHit
- Remove any results that don’t point sufficiently away from the target direction
- Choose the closest.
It broadly works. Once they get to a cover position, they will repeatedly fire at their chosen target if they can see it, or reposition on their next turn.
- Turrets will pick the most exposed enemy they can find, rather than the closest. There is one slight caveat: this is based on the number of Raycasts that hit the target, which may result in things like this.
- Suppression mechanics: dump enough ammo into the area around a target, and they lose their remaining action points. On their next turn, they’ll have half their total.
- Turrets no longer have 2-D aim. This took me the better part of a day to fix, and was the last issue added.
- Enemy units will try to relay the position of enemies to their comrades when spotting them.
- Sidestepping is no longer a free action. It now works by shifting the player units a guaranteed distance forwards/backwards/sideways, with a cost of 4 action points per unit moved.
- Toned down the sirens. Turrets still use this when spotting an enemy, but they have other noises. The humanoid enemies use a recording of Radio na Gaeltachta under heavy static.
- The player unit’s current path is now visible as a solid red line. I would like to make it dotted and translucent behind objects, but that’s another issue.
The next release will probably involve character models and a larger level to play in.