Change angle of camera: eulerAngle issue


in the pre-written script made by Unity, to make the camera follow an object, i would like the angle to not point towards “0” (eulerAngles.y here) but a bit more up, so that the camera is not pointing to the feet of my character.

But i can’t find out how to modify this, when i directly change the eulerAngle to a number, it rotates itself around the character from left to right instead of up/down.

Would you know how i could achieve this? (make the camera look a bit up, towards the trunk of the character for example)

Here is the code of the script attached to the camera (ball is the target) :

// Calculate the current rotation angles
    Debug.Log("ball.eulerAngles.y : "+ball.eulerAngles.y);
    var wantedRotationAngle = ball.eulerAngles.y;/* HERE, if i change the angle, it goes left/right instead of up/down)  */
    var wantedHeight = ball.position.y + height;

    var currentRotationAngle = transform.eulerAngles.y;
    var currentHeight = transform.position.y;

    // Damp the rotation around the y-axis
    currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);

    // Damp the height
    currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);

    // Convert the angle into a rotation
    var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);

    // Set the position of the camera on the x-z plane to:
    // distance meters behind the ball
    transform.position = ball.position;
    transform.position -= currentRotation * Vector3.forward * distance;

    // Set the height of the camera
    transform.position.y = currentHeight;

    // Always look at the ball
    transform.LookAt (ball);


The camera always look at the target pivot, as @OwenReinolds said. A possible solution (as @fafase said) is to child an empty object to the character, adjust its position to where the camera should aim at, and assign it to ball - this way the camera will follow the empty object, not the character.

But there’s another solution that would avoid changes in the character: instead of LookAt(ball) use the LookAt(Vector3) variant and define a position a little above the ball:

var offset: float = 0.5; // vertical distance above ball

// Always look at the ball
var pos = ball.position; // get the ball position...
pos.y += offset; // shift it vertically...
transform.LookAt (pos); // and turn the camera to the calculated position