Dealing Damage

The Slime behaves the way that we’d like, but it’s still not a “hazard” that warrants player caution. It needs to be able to deal damage to the player’s health. This is going to be broken down into two parts: a Component that tells the player they should take damage, and some adjustments to the PlayerStats Component so that it knows how to take damage.

Once the Slime can successfully deal damage to the player, we’ll update our pit trigger volumes to include damage. We’ll also grant the player temporary immunity after they take a hit so that they aren’t spammed with damage when struck by multiple enemies at once.

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.