624 Game Development and Simulation with Unreal Technology
IMPLEMENTING HIT FLASH ON ENEMY
Now, we will set up the network in blueprints responsible for showing a flash
on an enemy’s body w hen p la yer projectiles hit it.
15. Open u p the Enemy blueprin t.
16. Create a new variable called MeshMat in the Enemy event graph.
17. Change the type of this new variable to Material Interface. To do this, you
can either click on the drop -down box next to the Variable Type a nd search for
Material Interface in the search bar, or open the O bject Reference tab an d
scroll down to Material Interface (see Figure 9.54(a )).
(a) (b)
FIGURE 9.54: (a) A dding a Material Interface Variable. (b) Assigning Non-Fl ash (Regular)
Material.
18. Click on the Defaults section of the Enemy blueprint.
19. Scroll down to the Default rollout.
20. Click on the material selector next to the Mesh Mat .
21. From the drop-down menu, select and apply the same material our Enemy class
has (see Figure 9.54(b)). If you do not reme mber the material, perform the follow-
ing tasks:
a. Go to the Components tab.
b. Click o n the Enemy Mesh.
c. In the Details rollout, scroll down and find the Rendering section.
d. Expand the Materials item and see the material we applied to the element
[0].
e. Go back to the Defaults tab by clicking on it f rom the top toolbar.
f. Go to step 21 and find and apply the material.
22. Now, we will imp le ment th e network to make the Enemy shine with the Hit Flash
when hit, and turn back to its original material after a while (say a quarter of a
second).
a. Go to the event graph of the Enemy blueprint.
b. Find the network we created for the Enemy Damage Calculation ... in
step 12c on page 592.
c. Find the Branch node. Its True channel should be already connected to a
Destroy Actor node. This is because the branch tests for the Hitpoin t of
the enemy and if it is 0 or le ss, it destroys the E nemy.
d. We will use the Else channel to perform our HitFlash material swap.