Teleport Your Player

Posted on: June 23rd, 2015 by tdc_user
This tutorial describes how to teleport your player using Unity. Teleportation is cool because it is something we can’t do in reality, but can easily do in games. It can be used for so many purposes, such as teleporting the player from a death position to a restart position in the game, or for allowing the player to magically move from one distant peak to another in larger game areas. Setup:
  1. 1. You need a player (tagged as Player)
  2. 2. A cube or some other game object for the player to bump into (let’s name it triggerCube).
  3. 3. Make sure the cube has a collider which is set to Is Trigger.
  4. 4. You also need a gameobject named teleportTarget. This can be just an empty game object; the key thing is that it is at the location you want the player to be at after the teleport is complete.


Teleport Your Player

In the image above, the location of the player is specified by the P, the target location is specified by the X, and the triggerCube is highlighted on the left. When the player bumps into the triggerCube, they will automatically transport to the target location, wherever you have placed it. Then put the following script on the triggerCube: teleport.js Every time Player bumps into the triggerCube, the player will teleport to the new location, ie, the exact spot that teleportTarget is located on. Tags: , , ,

Comments are closed.