[SerializeField]
float runSpeed = 5f;
SpriteRenderer _sprite;
void Start () {
rBody2D = GetComponent<Rigidbody2D>();
_sprite = GetComponent <SpriteRenderer>();
}
void MoveHorizontally(){
float controlThrow = CrossPlatformInputManager.GetAxisRaw(“Horizontal”);
Vector2 playerVelocity = new Vector2(controlThrow * runSpeed, rBody2D.velocity.y);
rBody2D.velocity = playerVelocity;
flipSprite(controlThrow);
}
void flipSprite(float controlThrow)
{
if (controlThrow == -1) {
_sprite.flipX = true;
}
else
if (controlThrow == 1) {
_sprite.flipX = false;
}
}