---
title: Teleport Implementation
slug: world-sdk-guide/teleport-implementation
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

Implements a portal through which the ZEPETO character can teleport to two different points.



![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-xQUSTAIqb6XR3_ijDqhI3-20240904-102421.gif)



## STEP 1 : Setting the teleport target point



- Implement the ZEPETO character creation code in Scene as a default.

:::hint{type="info"}
**📘&#x20;**&#x50;lease refer to the following guide. \[[Create a ZEPETO Character](docId:_K4o-TkIw83Wg_jhy0ISA)]
:::



1\) Create points to teleport to.

- For this guide, we will refer to them as A and B points.
- Create a Hierarchy > 3D Object > Plane, and rename it to Plane\_A.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-YPfNLxuMmybV-RiO0UnQh-20240904-102421.png)



2\) Add a Portal object that will initiate a teleport.

- Be sure to add a Collider to interact with the object.
  - Adjust the size of the area to detect collisions.
  - Make sure to check Is Trigger.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-zsw3KDDtRnc65lbmesDh1-20240904-102421.png)



3\) Create a total of 2 teleportation points in the same way.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-esYtCDox6OMaljFjTWWNa-20240904-102421.png "Example of Teleport Point A")



![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-vB1mUIZBJCc8INMKDEr_A-20240904-102421.png "Example of Teleport Point B")



- Adjust the Position so that the points do not overlap.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-W8LMhFUKNiUbYj8h1QeEW-20240904-102421.png)



## STEP 2 : Write a script



1\) Create a Project > Create > ZEPETO > TypeScript and rename it to Teleport.

2\) Write a sample script like below.

- Logic to teleport with destinationObject when a collision with a ZEPETO character is detected in the collider area of the object to which the script is attached.

```typescript
import { Collider, Vector3, Quaternion, GameObject } from 'UnityEngine';
import { SpawnInfo, ZepetoCharacter, ZepetoPlayer, ZepetoPlayers } from 'ZEPETO.Character.Controller';
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
 
export default class Teleport extends ZepetoScriptBehaviour {
     
    // The destination object to be teleported to
    public destinationObject: GameObject;
 
    private _localCharacter: ZepetoCharacter;
 
    Start() {
        // Find the local player and Set it to _localCharacter
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
            this._localCharacter = ZepetoPlayers.instance.LocalPlayer.zepetoPlayer.character;
        });
    }
 
    OnTriggerEnter(collider: Collider) {
        // Do not execute the function if _localCharacter is not set yet or if the collided gameObject is not _localCharacter
        if (this._localCharacter == null || collider.gameObject != this._localCharacter.gameObject) {
            return;
        }
 
        // Teleport the _localCharacter to the position of destinationObject
        this._localCharacter.Teleport(this.destinationObject.transform.position, Quaternion.identity);
    }
}
```



3\) After you finish writing the script, add the script to the Portal object that will initiate the teleport.

4\) In the inspector, assign the Destination Object.

- Destination Object : a portal object to arrive at the end of the teleport.

::Image[]{src="https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-y-PuKoPDgX5mbE1uVnOUE-20240904-102421.png" size="62" width="424" height="601" position="center" showCaption="false"}



## STEP 3 : Run



Teleport the ZEPETO character from point A to point B when it is near the portal.

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-FjXBe_11wP8xMnFzwYT_M-20240904-102421.png)



:::hint{type="danger"}
- This guide only handles teleporting of Local Players that I manipulate.
- In the case of multiplayer worlds, synchronization of the location of other players is additionally required.
- Using the synchronization component of the multiplayer sample, position synchronization is easy to implement.
:::



:::hint{type="info"}
**📘 Multiplay Sample - Zepeto Multiplay Component**
[https://github.com/naverz/zepeto-multiplay-example/tree/main/Assets/Zepeto Multiplay Component](https://github.com/naverz/zepeto-multiplay-example/tree/main/Assets/Zepeto%20Multiplay%20Component)
:::

