You have this:
if(Input.GetAxis("Horizontal")) {
// Gamer pushes left arrow key
// Set texture to normal position
transform.localScale.x = -X;
}
else if (Input.GetAxis("Horizontal")) {
// Gamer pushes right arrow key
// Flip texture
transform.localScale.x = X;
}
The second else if will always be called because you are checking the exact same Input.GetAxis().
try something like this:
if (Input.GetAxis("Horizontal") < 0)
{
transform.localScale.x = -X;
}
else if (Input.GetAxis("Horizontal") > 0)
{
transform.localScale.x = X;
}
Input.GetAxis ("Horizontal") checks all left and right keys that could be pressed and spits out a number depending on either the left or right key...
Example If I were to press the 'Left Arrow' key, it would return a number between 0 and -1. If I were to press the 'Right Arrow' key, it would return a number between 0 and 1.
Does this make sense?