How can i limit a players movements to the screen without player shaking?

Hi, i’ve currently got a player which i am controlling with my mouse coordinates and i’ve tried limiting the boundaries for the player using mathf.clamp and also tried transforming its position to a new vector 2 and both of them end up causing player shake and i don’t know how to stop this.
code i’ve tried:
void FixedUpdate(){
if (transform.position.x <= gameSettings.playerBoundaries.xMin) {
transform.position = new Vector2(gameSettings.playerBoundaries.xMin, transform.position.y);
} else if(transform.position.x >= gameSettings.playerBoundaries.xMax){
transform.position = new Vector2(gameSettings.playerBoundaries.xMax, transform.position.y);

		if(transform.position.y <= gameSettings.playerBoundaries.yMin){
			transform.position = new Vector2(transform.position.x, gameSettings.playerBoundaries.yMin);
		}else if(transform.position.y>= gameSettings.playerBoundaries.yMax){
			transform.position = new Vector2(transform.position.x, gameSettings.playerBoundaries.yMax);

    void FixedUpdate(){
    rigidbody2D.position = new Vector3(

Nvm i put the transform.position code into update instead of fixedUpdate and it worked without causing the player to shake.