Making the player GameObject look left and right
2D Game Design with Unity
🕑 This lesson will take about 7 minutes
In this lesson, you will learn how to write some simple code that makes the player look in the direction that the player is walking. This can be easily achieved without having to create separate sprites for each direction the player will face. Instead, we can use a function to ‘flip’ the player to look in the direction it is moving.
The code to implement this will be added to the existing ‘PlayerController.cs’ script we have been working on in previous lessons throughout this course.
Game art, tiles and sprites from the Free Pixel Space Platform pack are used in this lesson video and can be downloaded from the Unity Asset Store.
Is YouTube blocked at school? Watch on Google Drive.
Sample code
Next lesson: Making the camera follow the player