Skip to main content
1 of 2
grillzeE
  • 57
  • 1
  • 4

Unity2D Sprite flips camera when moving left and right

I am using the Unity Engine and coding in C#.

I have a sprite as a parent with a main camera as a child so that the main camera follows the sprite. However, when pressing 'A' and 'D' to move the camera 'flips 180 degrees' due to me using transform.eulerangles is there anyway that the camera can be excluded from this 'flip'?

void Movement () { anim.SetFloat ("moveSpeed", Mathf.Abs (Input.GetAxisRaw ("Horizontal"))); if (Input.GetAxisRaw ("Horizontal") > 0) { transform.Translate (Vector3.right * moveSpeed * Time.deltaTime); transform.eulerAngles = new Vector2(0,0); } if (Input.GetAxisRaw ("Horizontal") < 0) { transform.Translate (Vector3.right * moveSpeed * Time.deltaTime); transform.eulerAngles = new Vector2(0,180); } } 
grillzeE
  • 57
  • 1
  • 4