private bool facingRight = false;
public void Update()
{
LookAtCursor();
pos = Camera.main.WorldToScreenPoint(transform.position);
}
public void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
public void LookAtCursor()
{
if(Input.mousePosition.x < pos.x && !facingRight) Flip();
else if (Input.mousePosition.x > pos.x && facingRight) Flip();
}