Health bar image is a children of an "Screen Space - overlay" Canvas and it has this code inside of it
void Update()
{
var wantedPos = Camera.main.WorldToScreenPoint(Enemy.position);
transform.position = new Vector3(wantedPos.x, wantedPos.y + 40, wantedPos.z);
}
but the problem is the health bar apear above enemy but it's not always in the center of enemy
here is a video to explain the problem more https://youtu.be/ZMWKxJvjy2o