Prevent Player Running of Map

So im trying to build a warcraft style MMORTS and I dont want the player to run off the map (terrain). Any suggestions? I have already tried placing a box collider around the map but I can walk through it for some reason.

Any and all help will be appreciated.

A box collider should work… You sure your doing it right?

You could always use the Vector3.distance() to calculate how far your player is from the middle of the terrain. When the player reaches a certain distance from the center, you would have him be respawned.

Something like:

var center = Vector3(0,0,0);

if (Vector3.Distance(center, transform.position) > 500) {
    // Respawn code goes here
}

The “500” and the 0,0,0 coordinates in that code are just an example. You can have whatever coordinates you like as your center, and set it to whatever distance you want…