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

Space Buddy the alien

We now add the main character in our game, which is the little alien named Space Buddy. To add the alien, we do the following:

  1. Download the alien.png image from the following URL:

    http://freeartsprites.com/platformer

  2. Move it to the sprites folder.
  3. Create a sprite GameObject using the following image:
    Space Buddy the alien
  4. Name the GameObject SpaceBuddy.
  5. Go to Add Component | Physics 2D | Rigidbody 2D.
  6. Go to Add Component | Physics 2D | Box Collider 2D.
  7. Go to Add Component | New Script and name the script SpaceBuddy.js.
  8. In the Project Browser, add a folder named Scripts and move SpaceBuddy.js into it.
  9. Add the following code to the script:

    Note

    The first line ...

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