# how do you make a map which can be circumnavigated?

im trying to make a map which if you go to one edge you appear at the otherside.

I have an example project showing how it works at this link: http://dl.dropbox.com/u/105851962/Wall_Test.zip

EDIT: Package with the solution - http://dl.dropbox.com/u/105851962/Circumvent_Package.zip

EDIT AGAIN: Links have been updated! (Should Work)

You can place Collider boxes at the edges of the map (assuming it is square) and simply position your character at the Collider box on the other side of the map with a bit of an offset so they don’t infinitely collide with a collider box and change their position.

So, if you character collides with the right side of the map, they would simply be transitioned to the left side of the map. Apply this script to your character:

``````using UnityEngine;
using System.Collections;

public class Circumvent2 : MonoBehaviour
{
//DISCLAIMER: Feel free to use this script and Projectfor whatever you need it for. - ThunderAwesome
///
/// Instructions
/// Assign all the wall GameObjects to their respective object.
/// Set the tags to each wall whatever it should be (I.E. - rightWall's tag is "Right_Wall")
/// Set the offset to whatever you want it to be...just make sure the character doesn't fly off the edge.
/// Offset should be positive for the Right and Top wall and negative for Left and Bottom...
/// Example: transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z);
/// Works with Right wall. AND transform.position = leftWall.transform.position + new Vector3(transform.position.x, 0, offset);
/// Works with Top wall. /// Example: transform.position = leftWall.transform.position + new Vector3(-offset, 0, transform.position.z); Works with Left wall.
/// Notice offset has a negative sign before it now.
/// Try implementing the other walls and taggin them correctly!
///
public GameObject leftWall;
public GameObject rightWall;
public GameObject topWall;
public GameObject bottomWall;

private float offset = 1.0f;

//used to set the Gameobjects to their respective
//object, so you don't have to assign them. Just make
//sure you name them correctly.
void Start()
{
leftWall = GameObject.Find("Left_Wall");
rightWall = GameObject.Find("Right_Wall");
topWall = GameObject.Find("Top_Wall");
bottomWall = GameObject.Find("Bottom_Wall");
}

//You'll need to have your Box Collider's isTrigger
//set to true for this function to work.
void OnTriggerEnter(Collider other)
{
//if the player collides with the rightWall
if(other.gameObject.name == "Right_Wall") //i usually check tags but this might work (can't test since I'm at work)
{
//set character position to left_wall + offset
transform.position = leftWall.transform.position + new Vector3(offset, 0, transform.position.z);
}
if(other.gameObject.name == "Left_Wall")
{
transform.position = rightWall.transform.position + new Vector3(-offset, 0, transform.position.z);
}
if(other.gameObject.name == "Top_Wall")
{
transform.position = bottomWall.transform.position + new Vector3(transform.position.x, 0, offset);
}
if(other.gameObject.name == "Bottom_Wall")
{
transform.position = topWall.transform.position + new Vector3(transform.position.x, 0, -offset);
}
}

//Inserted this to make debugging easier.
void Update()
{
//Press "R" to reset the scene
if(Input.GetKey(KeyCode.R))