Creating the Damage Trigger

We’re going to create a trigger for the express purpose of dealing damage to the player when they come into contact with it so that our Slime can injure them as it oozes its way through the game world. While we could leverage part of the Slime that we already have here, it would actually become a problem later on when we make some layer adjustments so that the player and enemies don’t physically collide. We’re simply going to nest a second GameObject under the enemySlime GameObject. Set one up as follows:

1. With the Slime selected, create an empty child GameObject and name it “triggerDamage.”

2. Add a Circle Collider 2D Component and check the “Is Trigger” box.

3. Set the Circle Collider 2D’s radius to 0.22. Set the ...

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.