Adding a simple animated character

Now that we have our background in the world, let's add in our player sprite:

  1. From the Art Assets folder included in the example code for the chapter, bring the three sprites for the plane into the Project tab's Assets/Sprites folder.
  2. Then, from the Assets folder, create a new folder named Animations.
  3. From there, select all three images (hold Ctrl and then select each of them) and then drag and drop them into the Scene tab to bring them into the level. You'll see a new window pop up that says Create New Animation. From there, browse to the Animations folder we just created and then open it. Afterwards, change the File name: property to PlaneFlying and then press Save. This will create an animation and controller that will automatically play it. We will talk about animations in more detail in the next chapter, but currently, this will always just play an animation using these three frames over and over again unless we stop it via code.
  4. The plane looks a bit large for me, so I'm going to change the Scale to .5, .5, 1. Next, we want the plane to be to the left side of the screen while also being seen from each resolution so then the Position to -2.5, 0, 0. In addition, let's rename the object Plane.
  5. Save your Gameplay scene in the Scenes folder and project and then play the game!
    Adding a simple animated character

At this point, the plane animates for us automatically, and it fits in all of our aspect ratios nicely!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset