My FlipSprite Method using SpriteRenderer.flipX

cud_s12_flip_character_sprite

#1

[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;
}
}


#2

Thanks for posting this. I really like how understandable this is set up.