Flipping a sprite horizontally – the DIY approach
Perhaps the simplest 2D animation is a simple flip, from facing left to facing right, or facing up to facing down, and so on. In this recipe, we'll add a cute bug sprite to the scene, and write a short script to flip its horizontal direction when the Left and Right arrow keys are pressed:

Getting ready
For this recipe, we have prepared the image you need in a folder named Sprites in folder 08_01
.
How to do it...
To flip an object horizontally with arrow key presses, follow these steps:
- Create a new Unity 2D project.
Note
If you are working in a project that was originally created in 3D, you can change the default project behavior (for example, new Sprite Textures
and Scene mode) to 2D via menu: Edit | Project Settings | Editor
, then choose 2D for the Default Behavior Mode
in the Inspector
.

- Import the provided image:
EnemyBug.png
. - Drag an instance of the red
Enemy Bug
image from theProject | Sprites
folder into the Scene. Position this GameObject...