mirror sprite unity code example
Example 1: unity mirror character
if (isRight == true && isLeft == false) { transform.eulerAngles = new Vector3(0, 0 ,0); } if (isRight == false && isLeft === true) { transform.eulerAngles = new Vector3(0, 180, 0); }
Example 2: unity c# flip sprite
public Camera cam;
public Transform aimTransform;
Vector3 mousePosition = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y));
Vector3 aimDirection = (mousePosition - transform.position).normalized;
float angle = Mathf.Atan2(aimDirection.y, aimDirection.x) * Mathf.Rad2Deg;
aimTransform.eulerAngles = new Vector3(0, 0, angle);