Flipping the Player

2D Mobile Game

Objective: Flipping the player depending on the direction of movement.

To flip the player, there are many ways but we are going to make use of the sprite renderer in the sprite to flip the player.

First of all create a reference variable and reference it to the sprite renderer component of the child gameobject.

Then below the horizontal input, set the condition to check if the input is less than 0.

If it results to true then it means the player is walking to the left and we flip the player in x-axis and if player is moving right then we set the flip to false thus changing the player direction to the right.

And this is the final result.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store