How to implement teleportation w/o collisions

Hi everyone,

I’m working on a game that implements seamlessly teleporting between two worlds. I’m new to Unity, and my first instinct was to make two terrains of identical size, parallel to each other, and 1000 Y units apart from each other. Then I created this script for Javascript to apply to the standard FPS module:

var universe = false;

function Update () {
	
	if(Input.GetKeyDown("x") && universe == false) {
		Camera.main.transform.position.y += 1000.0;
		universe = true; 
	}
	else if(Input.GetKeyDown("x") && universe == true) {
		Camera.main.transform.position.y -= 1000.0;
		universe = false; 
	}
}

Which works fine. When I press “X”, the camera essentially switches worlds, to the exact same X and Z coordinates, and translate 1000 Y units. My question is how to check if the place I’m teleporting to has an impassable object like a mountain or something there already, and to forbid teleporting to those places.

If anyone has a better idea of how to implement teleportation, feel free to share!

Thank you for your help in advance!

You might do a raycast from high above the destination point, straight down, and set the player to the x,z of teleport, and y of ray hit.

The teleports I’ve always seen have specific entry/exit points, so this does present an interesting twist.