How do i make it so that if i or my enemy moves left or right the camera moves to the opposite direction

basically camera lag but the camera doesn’t get centered when i stop moving
basically lock on but for Hack and Slash games
which i am making a Hack and Slash