Game Development Reference
In-Depth Information
5.
Create a new animation called
EnemyWalkingAnimation
and set
up the frames so that they create a ping pong effect similar to the
PlayerWalkingAnimation
file (see the following screenshot for reference).
6.
Rename the automatically generated animator controller named
Enemy
to
EnemyAnimatorController
, and then make sure that
the
EnemyWalkingAnimation
animation is placed within it as the
default animation.
7.
Make sure the
Enemy
object has a Box Collider 2D and a RigidBody 2D
component.
8.
On the
RigidBody 2D
component, set the
Collision Detection
property
as
Continuous
and set the
Gravity Scale
to
30
. The gravity scale property
is the degree to which this object is affected by gravity. In layman's terms,
higher numbers will make the object heavier. The actual size and shape of
the box collider on the enemy only needs to cover the center portion of the
treads. Therefore, it can be quite small—just large enough to let the enemy
stand on the ground.
9.
Set the
Size
of the
Box Collider 2D
component to
X: 1.71
,
Y: 0.95
and the
Center
component to
X: 0, Y: 0.49
.