how to confine the displacement of a bot to a certain space?

Hi, how do you confine the displacement of a bot to a certain space? I’ve seen examples of project Mecanim Example Scenes, but not really helped me.
See the picture below. I want my bot only walks in the green areas. How do I do that? Through mathematical formulas? I tried by creating gameObjects these areas but do not know how to access all of its points :S

System.Collections.Generic.List<Vector3> listPoints = new System.Collections.Generic.List<Vector3>();

foreach (Vector3 p in area.transform)
       listPoints .Add(p);

int rand = UnityEngine.Random.Range(1, listPoints .Count);
posDestiny.x = listPoints [rand].x;
posDestiny.y = 0;
posDestiny.z = listPoints [rand].z;

P.S.: Sorry i could not load the image, I had to do otherwise:

If you are using the pro version why don’t you save yourself the headache of writing a custom solution for that and use the NavMesh feature? It will be so much simpler to define areas your bots can and cant’ access.

Watch the video I linked you and if that’s the behavior you are looking for (towards the end), then I would recommend using NavMesh.