how can i make a health/attacks and player picture bar

hey everybody I want to know how i’m supposed to make a bar with a picture like this if you can point me in the direction of a tutorial or give me some part of the script for it that would be great i’m new to unity and i don’t know much about scripting the red bar is hte player’s health the black bar is his energy the little squares are his attacks the circle is the character and the little bar underneath it is map name

hm, can't see the image but from your explanation, i guess you mean something like a health bar a lot of rpgs have? like

theres a lot of ways to do it, if you want to use the unityGUI you'd need some textures (background, bars etc) and then use different gui calls in order to get the look, the order you call them is the order they get layered on top of each other.

heres an example, made only one bar for simplicity but you get the idea i hope.


using UnityEngine;
using System.Collections;

public class healthbar : MonoBehaviour 
    public int MaxHP = 100;    
    public int HP = 72;
    public string Name = "Character Name";

    void OnGUI()
        // some made up values,  in a real one you'd get them somewhere from your game
        int windowWidth = 200;
        int windowHeight = 80;

        // some made up textures, this part can be removed when you have actual textures for this.
        Texture2D texBG = new Texture2D(1, 1, TextureFormat.ARGB32, true);
        Texture2D texHP = new Texture2D(1, 1, TextureFormat.ARGB32, true);
        Texture2D texHPBG = new Texture2D(1, 1, TextureFormat.ARGB32, true);
        texBG.SetPixel(0, 0,;
        texHP.SetPixel(0, 0,;
        texHPBG.SetPixel(0, 0, new Color(.3F, .1F, .1F, 1));

        // check to make sure it stays within the maxHP
        if (HP > MaxHP)
            HP = MaxHP;
        if (HP < 0)
            HP = 0;

        // rendering

        // background texture
        GUI.DrawTexture(new Rect(10, 10, windowWidth, windowHeight), texBG, ScaleMode.StretchToFill);

        // name
        GUI.Label(new Rect(100, 12, 100, 30), Name);

        // hp bar background
        GUI.DrawTexture(new Rect(100, 35, MaxHP, 20), texHPBG, ScaleMode.StretchToFill);
        // hp bar current hp
        GUI.DrawTexture(new Rect(100, 35, HP, 20), texHP, ScaleMode.StretchToFill);

        // characters face texture
        GUI.DrawTexture(new Rect(12, 12, (windowHeight - 4), (windowHeight - 4)), texHP, ScaleMode.StretchToFill);  

personally though, if you want some complex gui stuff going on, i'd either look into creating your own gui solution with a secondary camera, or look into one of the existing gui systems (like NGUI or EZGUI or alike) in the asset store, as unityGUI is very high with drawcalls and it can also get very messy to setup in more complex systems.

@CanOfColliders the script works but how could i animate it and did you make the gui yourself or like how burgzergarcade did it in there tuorialhere