Changing Health Display GUI

Here’s hoping that this isn’t a duplicate.

TL;DR Background Here:

So, I’m doing a test for a game I’m helping to create. I’m testing every component of the game with things called “spaces”, something my physics teacher coined. So, the game itself is complicated as hell; the best way for me to learn how to program it is do trial and error and test with a crappy version along the way, effectively getting an idea on how I will process the game when actual development starts next year or so.

What I’m doing, at the moment, is called the “Battlespace”; those with military knowledge should know about that. To put it simply, it is the culmination of all forms and systems of combat in the game, since it is very combat-centric. So far, in the last few days, I’ve learned a lot. However, that’s probably because I have some minimal experience with programming.

TL;DR Background End

Anyways, I’ve run into a bit of an issue. I was thinking about how one would display enemy health within the GUI; at first, I thought “health bar”. But, I don’t like those at all, and our Creative Director agrees. I wanted a system where I could display the health of the enemy as a simple integer upon focus on them. Not only that, but I want it to be able to change.

Imagine if you created a calculator on a webpage, and using JavaScript you tell the calculator to do this, this, and this… the result of your actions are shown after you use it, being that the integer is changed right in front of you. I want to know if GUI Text will do that for me, or if there is something better than that.

I would prefer it to be in JavaScript, but use whatever is most comfortable as I could just parse the information I need from it :slight_smile:

If any pictures/examples of this potential GUI are needed, please tell me. Thank you in advance.

What exactly do you want to know? From what I understand, you just want to display a simple number over a unit that corresponds to the unit’s current health.

private var WorldNamePos : Vector3;
var Health : float = 100;

function OnGUI()
{
WorldNamePos = Camera.main.camera.WorldToScreenPoint(Vector3(transform.position.x, transform.position.y + 0.3, transform.position.z));
			    GUI.Label (Rect (WorldNamePos.x - 50, Screen.height - WorldNamePos.y - 64, 100, 50), Mathf.Round(Health) + "");
}