pop up damage on hit!!

Hi…
I have an RPG almost ready!! but i need some help with an issue…
i want it so as when the hits enemy, a damage number appears above the enemy and vice versa with player…
I have tried several scripts but nothing seems to work…
any help would be good…
thanx

You have some options, but the quick and dirty would be to create a 3d Text object when a player is hit, set it’s position to the hit player (moved slightly up on the Y axis) and set it’s color to Red (or green for healing). I’d make it a prefab so that it has a short timer script that destroys itself after a second or two.

Here’s a quick example (haven’t compiled it):

var hitPlayer = something_you_set_earlier; // hit game object (player)
var healthAmount = something_you_set_earlier; // damage or health
var healthIndicator = new GameObject();
 
var textMesh = healthIndicator .AddComponent<TestMesh>();
var meshRenderer = healthIndicator .AddComponent<MeshRenderer>();

if(healthAmount < 0) {
  // i.e negative, taking damage
  meshRenderer.material.color = Color.red;
} else {
  // i.e positive, gaining health
  meshRenderer.material.color = Color.green;
}

healthIndicator.text = healthAmount;
// move the health indicator to the player
// you'll need to change this line to place it where you want it relative
// to the hit player.
healthIndicator.transform.position = hitPlayer .transform.position;

A pre-made, out of the box solution would be NGUI. It’s not free, keep in mind, however it’s a great library and they’ve added strong component that does exactly what you’re looking for. (in fact if you look at this link, you can see it as part of the background picture with the ships) http://www.tasharen.com/?page_id=140