Game Development Reference
In-Depth Information
Completing the damage reports
Our last step in creating the damage report will be to add one line of code to the
ChangeBar() function:
HasChanged = true;
Setting this to true will allow us to run the ChangeBar() function again. We use
the bool variable so that the ChangeBar() function doesn't continually run in the
Update() function. If we didn't use the bool variable, our currentHealth would
run down past zero and the scale of our health bar would be in the negative.
Creating 3D name tags
The name tag is what will be used to show the player what the enemy's name and
level is. To create it, we'll perform similar steps as we did while creating the damage
reports. Our first step is to add a few variables:
public string Name = "Skeleton Warrior";
public int Level = 1;
public TextMesh NameTag;
We set all our variables here to public so that we can access them later. The Name
string is the enemy's name, the Level integer is the enemy's level, and TextMesh
NameTag is the object we use to represent the previous two variables.
Next, we will create a new function, which we will use to set the name tag. Add this
function to the bottom of your script:
void SetNameTag()
{
NameTag.text = Level + " " + Name;
}
Search WWH ::




Custom Search