camera rotates with player! how do i fix this?

I have trying for ages now, i have been looking through all the answers and different websites but all of the fixes are just giving me random compile errors.

I have so nearly finished my game all i have to do is fix this one last things then i am done.

Is there anyway i can fix it without importing assets?

heres my code (btw my camera is a child of the player(and yes i have tried unparenting it and adding a script))

	if(Input.GetKey(KeyCode.D))
		{
			rigidbody2D.velocity = new Vector2 (speed, rigidbody2D.velocity.y);
			transform.eulerAngles = new Vector2(0, 0);
		}
		else if(Input.GetKey(KeyCode.A))
		{
			rigidbody2D.velocity = new Vector2 (speed*-1, rigidbody2D.velocity.y);
			transform.eulerAngles = new Vector2(0, 180);
		}

thanks for the help and being patient enough to read this!

EDIT---------------------------------------------------------------------------------------------

I tried this:

		if(Input.GetKey(KeyCode.D))
		{
			rigidbody2D.velocity = new Vector2 (speed, rigidbody2D.velocity.y);
			transform.eulerAngles = new Vector2(0, 0);
			camera.transform.eulerAngles = new Vector2(0,0);
		}
		else if(Input.GetKey(KeyCode.A))
		{
			rigidbody2D.velocity = new Vector2 (speed*-1, rigidbody2D.velocity.y);
			transform.eulerAngles = new Vector2(0, 180);
			camera.transform.eulerAngles = new Vector2(0,0);
		}

And it kind of worked, the camera stays where it should and doesn’t rotate but :frowning: when the player moves to the left the whole world disappear except the background, why is this happening?

Thanks again!

I solved it!

It’s simple, If the camera is a child of the object then it will inherit the player positions so if the player rotates then the camera rotates with it

What you do is make the camera independent and get a script to control it

	public Transform player;
	private Vector3 offset;

	void Start () {
		offset = transform.position;
	}

	void LateUpdate ()
	{
		transform.position = player.transform.position + offset;
	}
}

This is what I use for a camera to follow people but make sure it is not a child of any objects

offset is where your camera is when the scene starts and then we simply make it so the player position is added to it