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 first need to create some obstacles to place in their way. In fact, our enemies will change direction every time they collide with an obstacle.
We can achieve this by dragging boxAlt
from the Project panel under Platformer Pack | Tiles inside the scene...