Trying to clamp the movement of a rigidbody2D

I’m trying to limit movement to inside a certain area.

In 3d Unity I could do this (from the Project: Space Shooter):

 rigidbody.position = new Vector3 
        (
            Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax), 
            0.0f, 
            Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
        );

However, rigidbody2D doesn’t have a .position. I tried using transform but I am clearly confused on some part of it as I was getting an error from it.

I replaced the code you have above with this (while using rigidbody2D):

		transform.position = new Vector3 (
			Mathf.Clamp (transform.position.x, boundary.xMin, boundary.xMax),
			0.0f,
			Mathf.Clamp (transform.position.z, boundary.zMin, boundary.zMax));

Hope that helps.