I'm modifing a game based on the turret defence game template .
I want to add a health bar to each new enemy, so when an enemy is spawned I also spawn an healthBar spite and pin it to the enemy. Every time the enemy is hit I modify the healthBar width to enemy's health instance variable.
This method doesn't work as all healthBar on the screen get the same value and are destroyed when the first enemy is detroyed...
Spawning a healthBar when Spawning a new enemy
Adjusting the healthBar as enemy gets hit
How can I adjust the only hit enemy's healthBar?
How can I destroy the healthBar when the enemy iss dead?