Editing 2 position axes

So, I’m trying to control a camera. The camera is supposed to follow the player and move up and down fluidly in places that I will set a Trigger in.
The x axis is determined like this:

float playerX = player.transform.position.x;
		float cameraX = playerX + 20;

The Z axis is simply:

player.transform.position.z

Now, the Y axis is not supposed to be edited by the coding in any way, since it is controlled by a mecanim animation. Now comes the problem:

I can’t just plug in the two values, since Unity then calls me out because transform.position.x and z are not variables and cannot be edited.

But if I use a Vector3 like this:

float playerX = player.transform.position.x;
		float cameraX = playerX + 20;
        Vector3 cameraTransform = transform.position;
        cameraTransform.x = cameraX;
        cameraTransform.z = player.transform.position.z;
        transform.position = cameraTransform;

The Vector3.y always overwrites the animation, so it might just not play at all. How can I leave the Y axis alone?

I appreciate any help.

If you have a problem with the animation overriding your code, consider putting the code into LateUpdate, as this will get called after transformations due to animations have been applied.