A Top-Down Game with Blueprints 587
FIGURE 9.23: Destroy Projectile on E vent Hit.
In this tutorial we established our collision system. This is a very important part,
since the collision system will create a mechanism for us to be able to detect
when hit events occur.
We will use these hit events for the player to detect when he is hit by the
enemy to activate a damage functionality. The same logic goes for the enemy’s
collision events.
The projectiles’ collision system will also let us detect when th ey hit a wall or
an enemy. We will use these events to decide to cast damage on the enemy and
to destroy the projectiles, when they hit an object.
We first established three co llision object ch annels in the Coll ision cate-
gory of our Project Settings. This will help later on to assign these channels
as presets when we wish to establish collisions in our cla ss blueprints, and to
streamline the process.
After setting our collision system up for the player and the projectile class, we
perfor med one last mod ifica tion to the p rojectile class. This modification allows
the pr ojectile objects to simulate hit events. We use these hit events to damage
the enemy and to de stroy the projectile when it hits an enemy or a wall.
9.6 CREATING THE ENEMY CLASS AND IMPLEMENTIN G
DAMAGE
Now that our play er interac tions and the projectiles are created, it is time to shift
our focus to another equally important aspect of the game – th e enem y. In th e next
few set of tutorials, we will go over the enemy class and populate it w ith the needed
functionality, both in terms of taking damage from being hit and casting damage to
the player.