O'Reilly logo

Learning Unity 2D Game Development by Example by Venita Pereira

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

Animating the hero

The next thing we need to do is add a hero to the game. We will want to animate our hero as our hero is organic and not an inanimate object. We download and unzip the hero's sprite sheet WizardSpriteSheet.png from the following URL:

http://freeartsprites.com/roguelike/

The Wizard sprite sheet is shown in the following image:

Animating the hero
  1. Slice the sprite sheet using the grid option, and use the dimensions X = 348, Y = 384, and Pivot = Center.
  2. Create a hero GameObject. Name the GameObject hero.
  3. Add a Box Collider by going to Add Component | Physics 2D | Box Collider 2D.

We now create the first animation of the hero walking down.

The Walking Down ...

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