O'Reilly logo

Unity 5.x 2D Game Development Blueprints by Abdelrahman Saher, Francesco Sapio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding enemies

To make our level more exciting, we need to add some enemies to the level. We can use the sprites under Platformer Pack | Enemies and start by creating the snail enemy.

Just like how we animated our player, we will do almost the same for the enemies; drag and drop both snailWalk1 and snailWalk2 into the scene to create the animation. Then, rename the object to Enemy1, scale the object to (-3,3,3), so that it fits the dimensions of our game level, and then place it on the first platform of the level. Finally, add a box collider that fully encloses the sprite and a rigid body with its FixedAngle variable set to true. As a result, the Inspector should look like the following:

Before going forward with the enemies and their code, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required