How to limit movement using Mathf.Clamp

I’m extremely new to coding and have been looking through the tutorials but I can seem to find my answer. I’m trying to limit the area my character can move in a box shape but everything I’ve tried so far has not been successful. Here is the code I’m using for character movement, taken from the first game tutorial.

using UnityEngine;
using System.Collections;

public class Player1Movement : MonoBehaviour {
	
	public float speed;
	
	void Start ()
	{
		gameObject.renderer.material.color = Color.red;
	}
	
	void FixedUpdate () {
		float moveHorizontal = Input.GetAxisRaw ("Horizontal");
		float moveVertical = Input.GetAxisRaw ("Vertical");
		
		Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
		
		rigidbody.AddForce(movement * speed * Time.deltaTime);
	}

}

My question is where would I add Mathf.Clamp so that I can limit the movement? Everywhere I’ve tried putting into so far has not yielded the results I want.

You could try to clamp the position inside FixedUpdate:

void FixedUpdate(){
  Vector3 pos = rigidbody.position;
  pos.x = Mathf.Clamp(pos.x, minX, maxX);
  pos.y = Mathf.Clamp(pos.y, minY, maxY);
  pos.z = Mathf.Clamp(pos.z, minZ, maxZ);
  rigidbody.position = pos;
  float moveHorizontal = Input.GetAxisRaw ("Horizontal");
  ...

But the result may look very artificial. Since you’re using forces to move the rigidbody, maybe a better solution would be to limit the area with simple colliders: create an empty object (menu GameObject/Create Empty) and add a box collider to it (menu Component/Physics/Box Collider), then adjust its position and dimensions in order to limit one of the sides; repeat this for the other sides until all the area is delimited. These colliders behave like invisible walls, fully constraining the movement.