Make your enemy flash when hit

Objective: Let’s make the enemy show some sort of hit detection when smacked.

It’s generally not enough to hit an enemy and not see any sort of feedback. Let’s add a simple way to see the damage an enemy takes during runtime. To start, let’s change the emission channel from a map to a flat color.

Then in script, we want to make sure that emission is black on start.

Afterwards, let’s create a coroutine that alters the color as it takes damage.

Finally, let’s add the coroutine to our damage script so whenever out enemy takes damage, the flick white for .05f then back to normal.