Health script? That uses tags

Hi, this is my first time here, I was just wondering how to make a health bar for a 2d game with guns. I was hoping to use tagged bullets to do this but my script wasnt working.(sorry can't post it I'm im on my iPod.) and also I didn't want to change the pixel inset I wanted to change the actual size of it and take off like a small part if it when I get hit.

So, just to get this right. You want to create a healthbar, e.g. a horizontal bar with a green bar and some sort of background for the energy bar. One way of doing this is to do it on the GUI layer and use two textures. Like this:


<pre>`public float maxHealth = 100.0f; // Minimum health is 0.0f (dead)
public float currentHealth = 100.0f; // Players current health

// Just set them in the inspector
public Texture2D background = null;
public Texture2D energybar = null;

void OnGUI()
    // Draw the background
    GUI.DrawTexture(new Rect(32.0f, 32.0f, 128.0f, 16.0f), background);

    // Draw the health/energy bar
    GUI.BeginGroup(new Rect(34.0f, 34.0f, 124.0f * (currentHealth / maxHealth), 12.0f));
        GUI.DrawTexture(new Rect(0.0f, 0.0f, 124.0f, 12.0f), energybar);

` Try using a red texture for the energybar and a green for the background. Then you have a very simple health bar.