Teleporting the Player in 3D Game Kit

Revisado con versión: 2018.1


Dificultad: Principiante

We have a teleporting system in the Game Kit. You can teleport Ellen to other Levels or to different places within your scene.

Let’s create a Teleporter within a scene:

  • In the Project Window go to Prefabs > Environment > Structures

  • Find GateWayHugeTeleporter

As the name suggests this Gateway is huge:

  • Use the Scale Tool and Translate Tools to position it and scale it to Ellen's size

  • In the Hierarchy expand GatewayHugeTeleporter to expose its children

  • Select TeleportPlane

  • Navigate to the Inspector

  • Click Add Component

  • Search for BoxCollider

  • Hit Enter on your Keyboard or Click on BoxCollider to add the Component to TeleportPlane

  • On the Box Collider Component tick Is Trigger

  • Click Add Component

  • Search for Teleporter

  • Hit Enter on the Keyboard or click on the Teleporter Script to add it to TeleportPlane

  • In the Teleporter Component

  • Change the Layer to Player

  • In the Hierarchy, locate the Checkpoints

  • Click on the arrow next to Checkpoint to expand its children

  • With TeleporterPlane selected in the Hierarchy

  • Drag Checkpoint (The child) into the Destination Transform field of the Teleporter Component

  • In the Hiearchy find and expand Ellen to reveal its children

  • Find RespawnParticles

  • With GateWayHugeTeleporter selected in the Hierarchy

  • Drag RespawnParticles into Enter Effect on the Teleporter

  • Drag RespawnParticles into Exit Effect on the Teleporter

  • Press Play and test by running into the teleporter

When walking through the teleporter, Ellen will teleport to the location where she initially spawns and blue particles will surround her.