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:
![alt text][1]
what we currently have and don't want (green arrows are the correct ones):
![alt text][2]
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?
[1]: /storage/temp/17234-frage1.jpg
[2]: /storage/temp/17235-frage2.jpg
↧