Integrate your character controller

Integration

In each included demo scene you can find a Player gameobject, which already has the teleport functionality built in. But since you probably have an own controller and do not want to use the one of mine, here is a separate PlayerTeleporter script that isolates the player teleport functionality and makes the integration with your own character much easier.

Let's assume you have the same structure as my controller: Player (Root object with your player/CharacterController)

  • Camera

  • Capsule

To add the teleport feature to your character follow these steps:

  • Add PlayerTeleporter to your root object

  • Assign the portable object (Object that contains the Character mesh to be cloned)

    • In our case this is the Capsule

  • Go to your player camera and attach the MainCamera script to it. This will make sure that the portal views are updated and rendered properly.

And that's basically it, you have now added the teleport functionality to your own Character.

Example: Teleport integration with Starter Assets First Person Controller

Since each Character Controller could have different structures, here you have an example of a different structure where the Player and the main camera are 2 different root objects. For this example I used the Free Package: Starter Assets: Character Controllers | URP

As you can see, the PlayerCapsule and MainCamera are separated, but the principle stays the same:

  • Add PlayerTeleporter to your Player root object

  • Add MainCamera script to your player camera

The only thing you want to make sure is that your CharacterController and your cloned mesh are not in the same GameObject. You want to have your mesh separated since otherwise cloning the portable object would clone the character controller too, and not only the character mesh.

Last updated