Camera follow x axis


Is there anyway to move my camera only in x axis?
here’s my setting and movement code


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMove : MonoBehaviour
{
    public float maxSpeed;
    public float jumpPower;
    Rigidbody2D rigid;
    SpriteRenderer spriteRenderer;
    Animator anim;

    void Awake(){
        rigid=GetComponent<Rigidbody2D>();
        spriteRenderer=GetComponent<SpriteRenderer>();
        anim=GetComponent<Animator>();
    }

    void Update(){

        //Jump
        if(Input.GetButtonDown("Jump")&&!anim.GetBool("isJump")){
            rigid.AddForce(Vector2.up*jumpPower,ForceMode2D.Impulse);
            anim.SetBool("isJump",true);
        }
        //Stop Speed
        if(Input.GetButtonUp("Horizontal")){
            rigid.velocity=new Vector2(rigid.velocity.normalized.x*0.5f,rigid.velocity.y);
        }
        //Direction Sprite
        if(Input.GetButton("Horizontal"))
        {
            spriteRenderer.flipX=Input.GetAxisRaw("Horizontal")==-1;
        }
        //Animation
        if(Mathf.Abs(rigid.velocity.x)<0.3)
        {
            anim.SetBool("isWalk",false);
        }

        else
        {
            anim.SetBool("isWalk",true);
        }
    }

    void FixedUpdate(){
        //Move Speed
        float h=Input.GetAxisRaw(("Horizontal"));
        rigid.AddForce(Vector2.right*h,ForceMode2D.Impulse);

        //Max Speed
        if(rigid.velocity.x>maxSpeed){
            rigid.velocity=new Vector2(maxSpeed,rigid.velocity.y);
        }

        else if(rigid.velocity.x<maxSpeed*(-1)){
            rigid.velocity=new Vector2(maxSpeed*(-1),rigid.velocity.y);
        }

        //Landing Platform
        Debug.DrawRay(rigid.position,Vector3.down*1.25f,new Color(0,1,0));
        RaycastHit2D rayHit=Physics2D.Raycast(rigid.position,Vector3.down*1.25f,1,LayerMask.GetMask("Platform"));

        if(rayHit.collider!=null){
            if(rayHit.distance<0.96f)
            {
                anim.SetBool("isJump",false);
            }
        }

    }
}

Camera stuff is pretty tricky… you may wish to consider using Cinemachine from the Unity Package Manager.

There’s even a dedicated forum: Unity Engine - Unity Discussions

its easy, but you didnt even show your camera code

It’s also not a post for the 2D forums. It’s UI and/or Scripting.

As I stated here: Player doesn't move when Camera follow player - Unity Engine - Unity Discussions

Moved.