Camera target block "x"

I’m making a 2d game. In this my camera follows my player, but only in the “y” direction. If my character moves in the “x” direction, the camera should not follow my character. At the moment the “y” movement works, but how can I do it with “x”?

You just should not change x position of your cam :wink:
Nobody can give you right advice without your code.

if there is a code like this in your camera script. transform.position=target.position change it to transform.position.y=target.position.y thats all.

It will work only with JS.
In C# need to change whole vector:

transform.position= new Vector3(fixedXValue, target.position.y, target.position.z);