How to remedy jitters in this chase script?

I’m reaching out for help on this one. I have been trying to get a friendly to smooth follow the player in 2D. I’m currently getting jitters for the friendly when it reaches the limit as declared by maxDistanceX, this is when having both

“rigidbody2D.velocity = new
Vector2(velocityX, 0);”

commented out so that

“myTransform.position -=
myTransform.right * Time.deltaTime;”

(or its inverse) dictates x-axis translation.

When the “rigidbody2D.velocity = new Vector2(velocityX, 0);” line is included the jitters are there in the x-movement regardless of reach the max distance; the objective is to have the companion obey the players x velocity when changed and to slow to a halt if limit reached, yet otherwise if the maxDistanceX is reached and the player does walk to have the companion move as well without the jitter. Also does anyone have any ideas as to how to implement a velocity increase when further and decrease velocity to a halt when the limit is reached?

	void companionMovement() {
		xMax = myTransform.position.x + xLimit;
		xMin = myTransform.position.x - xLimit;
		velocityX = playerAttributes.xSpeed;

		companionVelocity = rigidbody2D.velocity.x;

		dirX = Mathf.Abs(target.position.x - myTransform.position.x);
		if(dirX > maxDistanceX){	
			if(target.position.x < myTransform.position.x){
				myTransform.position -= myTransform.right * Time.deltaTime; 
				rigidbody2D.velocity = new Vector2(velocityX, 0);
			} else if (target.position.x > myTransform.position.x){
				myTransform.position += myTransform.right * Time.deltaTime; 
				rigidbody2D.velocity = new Vector2(velocityX, 0);
			}
		}
	}
	
	void companionJump() {
		isOn = Physics2D.Linecast(transform.position, new Vector3(myTransform.position.x,rayYp,0), 1 << LayerMask.NameToLayer("Player"));

		if (isOn){
			wasOn = true;
		} else if(wasOn && !jumpTrigger){
			wasOn = false;
		}

		dirY = Mathf.Abs(target.position.y - myTransform.position.y);
		if(dirY > maxDistanceY && isOn && playerJump && jumpTrigger){
			rigidbody2D.AddForce (new Vector2(0, jumpHeight * 1.25f));
		}

Maybe this will be of some use to you :
Hysteresis