Unit behaviour
The base unit behaviour has been carried over from my previous Unity project. The player will be able to add enemies to unit attack queues, and units will pursue any enemies in range by default.
Enemy behaviour
I've also added enemies to the scene. These enemies follow the same development principles as the controllable units in terms of unit data. The only component thus far that varies from the existing scripts is the movements of
hostile units (since their behaviour is distinctly separate in terms of player interaction and targe detection).
Projectiles
Test projectiles have been added to the game, making the unit behaviour script components flexible and configurable based on how many projectile origins there are and whether the projectiles are guided. I’ve made it so that there
are currently primary weapons for both playable and hostile units, with the options to expand to secondary functionalities.
Docking path routines
I’ve refined the functionality for a unit to depart from and be recalled back to its parent dock. One of the aspects which I’ve considered is the unit’s position and rotations ‘lerping’ from one navigation node to another.
Especially for the recall action, the unit will rotate towards the first return route node of the parent dock. Once within range, it will orient itself in the direction of the parent dock. From there, it will lerp through the
remaining docking nodes until it rests at the final node, where the return process is completed. I’ve also had to configure how the unit’s other movements like enemy detection and target caching will be disabled, suspended or
cleared once the recall has been put into action.
I’ll need to think of a way to abort the return process if the unit hasn’t yet reached the first return node. This is because the player might react to nearby events that could pull the priority of the returning unit. The plan is to
intercept the logic in an existing ‘if’ condition that defines the logic mentioned previously to navigate to the first return node. This means that if the unit has not yet started the docking procedure, the player can divert its course.
Unit selection
Selection outlines on buildings and units have been added. When toggling the outline component, I had to add an additional check to ensure that the dissolve effect had completed before allowing the outline render toggle, as
triggering the outline while the dissolve effect was taking place would cause the render to remain even when the entity is no longer selected. This is because the outline would still reference the initial dissolve shader materials.
When adding visual effects such as engine propulsion trails to the units, the outline component was throwing warnings to the console due to the VFX renderer component not being compatible with the logic. As a result, I modified
the outline component to sanitise the initial renderer array by converting to a list, filtering out renderers that contained VFX renderers, and replacing the array with the filtered list. This stopped the warnings from showing,
and gives more confidence in applying VFX to more selectable objects in the future free of warnings.
Unit allocation
There is a 1:1 relationship between a production building and a unit. The buildings now reference the allocated unit, in a similar way to how units currently reference their parent buildings for their recall functionality. This means that
the player is no longer able to build another unit in a given production building if its allocation slot is currently occupied.
Sources Referenced: