3D - Move this player lean script (Leaning to the right) to the left. (EASY)


I have this older lean script that only works when going to the right. What I want to know, is how I can make it move to the left instead.

So the code below angles/moves/rotates the camera to the right, so the player can see past walls and such. All I need is, it go to the left instead.

Keep in mind it is not the full code, so if you want that to test it out or use the script yourself, please ask.

if(Input.GetKey(KeyCode.E)) {
		isLeaning = true;
		if(curLean < leanSize) {
			Camera.main.transform.Translate(leanSpeed * Time.deltaTime, 0, 0);
			if(leanSize > 0.6) {
				Camera.main.transform.Rotate(0, 0, leanSpeed * Time.deltaTime * -1 * leanAngle);
			curLean += leanSpeed * Time.deltaTime;
	if(Input.GetKeyUp(KeyCode.E)) {
		isLeaning = false;

if(curLean > 0.01 && (!isLeaning)) {
		Camera.main.transform.Translate(leanSpeed * Time.deltaTime * -1, 0, 0);
		Camera.main.transform.Rotate(0, 0, leanSpeed * Time.deltaTime * 1 * leanAngle);
		curLean -= leanSpeed * Time.deltaTime;


Got it to work! Thanks! What we missed was to make the leanback if statement be seperate for left and right by making them functions. These functions are now called upon when the E or Q key get UP, so basically when you stop leaning.

This way I could simply change the 1, and -1 around, into -1, and 1 for it to work for the left side.