-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Unity 2020 By Example - Third Edition
By :
In this section, we will create the damage system for our game. Assuming that it will take more than one hit to destroy an enemy, we need to create a way to track health. We then need a way to reduce health – a weapons system. In previous chapters, we've created projectile Prefabs that would damage an enemy on collision. In this chapter, we'll do things slightly differently. By taking advantage of collidable particle effects, we'll create a visually appealing projectile system. Let's start by implementing the health system.
The enemy objects and the player must be able to take damage when hit by weapons. Therefore, both the player and the enemies require a way to track their current health. To accomplish this, we'll create one script that we can reuse for both entities:
Assets/Scripts folder, create a new Health script:public class Health : MonoBehaviour
{
public...