From the course: Unity 5: Network Gaming
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Adding a health indicator, part 3 - Unity Tutorial
From the course: Unity 5: Network Gaming
Adding a health indicator, part 3
- [Instructor] We need a way to show the health score on each player. There's several ways to do this. I usually use a really nice health bar I found on the Assets store, but while I'm prototyping, I usually just use a text box. This isn't visually perfect, but it's good enough for prototypes. Since I'm in the code, I think I'll go ahead and write the code for it first. I'm going to add a reference to the UI framework. So, using UnityEngine.UI. We're going to be using a text box, and in order to access the text box class, we're going to need a reference to the UI framework. Next, I'll go ahead and make a field to hold the text box, and I'll just call that HealthScore. Next, I'll go down to start and I'll go ahead and set Health Score's value as soon as the tank is instantiated. So, I'll say HealthScore.text equals current health. Next, I need to go down to TakeDamage and I need to set it here as well. I'll add it into the bottom of the else statement. That's it for the code. So, let's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Project overview3m 15s
-
(Locked)
Set up the Network Manager2m 11s
-
(Locked)
Network identity3m 1s
-
(Locked)
Testing the game3m 46s
-
(Locked)
Network transform6m 58s
-
(Locked)
The local player6m 26s
-
(Locked)
Instantiate projectiles6m 58s
-
(Locked)
Firing projectiles6m 5s
-
(Locked)
Multplayer projectiles5m 2s
-
(Locked)
Adding a health indicator, part 12m 53s
-
(Locked)
Adding a health indicator, part 23m 44s
-
(Locked)
Adding a health indicator, part 34m 46s
-
(Locked)
Multiplayer health5m 54s
-
(Locked)
Fragging the enemy5m
-
(Locked)
Respawning6m 14s
-
(Locked)
-