[Project Week 20] Enemy GUI tweaks

Tweaks to the enemy GUI

Now that we can show the enemy GUI and have it update after attacking the enemy, but I now need to tweak it so the enemy GUI disappears after they die.

Code

So first of all I created a new public delegate and event called CharacterRemoved:





And then I created a new function called OnCharacterRemoved:



And then in the death behavior script I changed one of the lines of code from destroy game object to animator getComponent and then the character removed function, so when the character is removed it activated the function and triggers the event:



And then in the UIManager I also added this line of code to hide the unit frame from the user interface so I don't have a target when the enemy is gone from the game:



Now i need to use the NPC's function called de select because theere is a bug when selecting a new enemy it carries over the health of the previous enemy, so now once I unselect the current enemy it shouldn't update the next target with the previous enemies health:



Another bug is when after attacking an enemy it loses health, when I select a new enemy the bar fills up from the previous targets current health, when it should just show the next targets current health without the fill.

To fix this I needed to go to the stats script and add this line of code, this means every time I initialize something it will have the correct value right away:

Comments