Check out example codes for "how to make player flip when pressing a d unity 2d". It will help you in understanding the concepts better.

Code Example 1

void  Update ()
    {  //This short code makes player flip when the A and D or arrow keys are pressed.

        Vector3 charecterScale = transform.localScale;
        if (Input.GetAxis("Horizontal") < 0)
        {
            charecterScale.x = -10;
        } 
        if (Input.GetAxis("Horizontal") > 0)
        {
            charecterScale.x = 10;
        }
        transform.localScale = charecterScale;
    }

Code Example 2

if (isRight == true && isLeft == false) {         transform.eulerAngles = new Vector3(0, 0 ,0);   }   if (isRight == false && isLeft === true) {         transform.eulerAngles = new Vector3(0, 180, 0);   }

Learn ReactJs, React Native from akashmittal.com