Camera always 90 degrees to player (curved path)

Hello togehter,

a friend and me have some issues with our camera movement.

We have a curved path and our player moves along it.

We want that our camera always looks at our player in a 90 degree angle. It should not matter in which rotation or position the player currently is. Additionaly the camera should see the player only from one side.

look at our beautiful pictures for reference (black stuff is path, arrows are camera rotation ):

what we want:


what we currently have and don’t want (green arrows are the correct ones):


First Solution:

		if (target) {
			transform.position = new Vector3 (target.position.x, target.position.y, target.position.z);
			if (controllerScript.characterDirection == Controller.Direction.Forward) {
				transform.rotation = new Quaternion (target.rotation.x, target.rotation.y, target.rotation.z, target.rotation.w);
			if (controllerScript.characterDirection == Controller.Direction.Reverse) {
				transform.rotation = new Quaternion (target.rotation.x, target.rotation.y - 1, target.rotation.z, target.rotation.w);
		transform.Translate (cameraDistance, cameraYOffset, 0);
		transform.LookAt (target);

This works fine, but in a curve the camera has a strange x-offset.
Our camera is not child of the player

Second solution:

The camera is a child of the player. This works fine for one direction, but if we change the direction, the camera changes its rotation, because it is child. This is completely logical, but we don’t want this rotation.

Our Question is: Is there a way to prevent the rotation?

We are using iTween. Is there a method we are currently unaware of that could help us?

Making camera a child is the best way to go in my opinion. What you can do, once the player changes direction, move the camera so that it is on the other side.

To change the position of the camera to be the exact opposite of the player from its current position:

camera.transform.localPosition = -camera.transform.localPosition; // move the camera to the opposite side of the player. Assuming camera is child of player.
camera.transform.LookAt(camrea.transform.parent.position); // turn the camera so that it faces the player