Enemy Health Scale

Hi, I was wondering if someone could guide me on the right path for my problem. I was able to set up an HP bar for my enemies, but their scale always stays the same even when they’re far away. Is there a way to make it so that the HP bar’s scale would be relative to the enemy it’s attached to and not the camera?

This is the script I have so far:

function Update () {

	myHB.transform.position = Camera.main.WorldToViewportPoint(transform.position);
	myHB.transform.position.x -=  0.05;
	myHB.transform.position.y +=  0.3;
	myHB.transform.localScale = Vector3.zero;

	var healthPercent: float = curHealth / maxHealth;

	healthBarWidth = healthPercent * 64;
	myHB.guiTexture.pixelInset = Rect(10,10,healthBarWidth,4);
}

Instead of using the slow Unity GUI features, just use a billboarded, unlit mesh that’s a child of the enemy? You could scale the width of the mesh to make it correspond to the enemies health.