Custom Camera Rotation

Hello, so I am building my games camera from scratch to be based around my model rather than use the built in controllers. I started by making a capsule just to pretend it’s my character.

Then I added an empty object on top of the capsule parent to base my x,y,z off of and then put a child camera in that. So now I have a script attached to the empty object that is child to the capsule. I call the rotation simply by doing the following.

#pragma strict
var rotatespeed = 3;
var rotationstart = 90;
function Start () {

}

function Update () {
	if (Input.GetKey ("q"))
			//print ("q key was pressed");
			this.transform.Rotate(Vector3.up * rotatespeed);
	if (Input.GetKey ("e"))
			//print ("e key was pressed");
			this.transform.Rotate(Vector3.down * rotatespeed);
	if (Input.GetKeyDown ("space"))
			//print ("space key was pressed");
			this.transform.Rotate(0, rotationstart, 0);
			
}

So what am I trying to do? Well when the q and e keys are pressed I want the camera to rotate around my player. So far this works. I now want the spacebar to reset the camera to behind the player. I tried doing this by making a variable that equals the starting position of the empty object holding the camera. Then when space is pressed it sets the rotation to that point. However, I clearly have failed on that as the script constantly adds the rotationstart variable to the current rotation none stop instead of replacing it. So I wasn’t sure how to set that objects rotation back to it’s starting position.

Never mind. To anyone who wants to know how to fixed it I changed the rotation script in the space keydown function to just transform to a new vector like so.

this.transform.localEulerAngles = new Vector3(0,rotationstart,0);