Final Major Project - Combat Zones
Combat Zones are my method of controlling encounters. They serve as the boundaries for encounters and also allow me to control all enemies in an encounter with ease.
The Combat Zone is an empty game object that has a sphere collider and the Combat Zone script on it. On start the scrip uses a physics overlap sphere to gather all on the enemies inside it radius, which is set by slider on the inspector. This selected radius is also used to set the radius of the sphere collider on start too.
All of the enemies gathered are then stored in a list on the combat zone. Using the sphere collider to trigger OnTriggerEnter and OnTriggerExit functions the player keeps track of what combat zone they are in and can refer to it to access encounter specific details like the respawn position for that zone. The exit trigger is used to get all enemies to retreat if the player leaves the zone, preventing the player luring enemies to nonsensical areas like the populated town.
Having access to enemies in a specific encounter also allows the zone to have functions that, for example, set all enemies in the zone passive. This is used on player death so that enemies in the zone don't continue to attack a dead body. The Combat Zone also makes use of Unity Events to allow custom functionality to be added, the events are triggered when all enemies in the zones list are dead and on reset (respawn). This makes quest design infinitely easier as it allows me to very simple set up a scenario where a pick or note is not interactable until all enemies have been killed.
The functionality afforded to me by creating these combat zones will accelerate the quest design and content implementation process greatly, giving huge benefits in the long run and I am very pleased that I had the forethought to develop it.