Studio GuideWorld SDK Guide
Log In
World SDK Guide

Teleport Implementation

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


800

STEP 1 : Setting the teleport target point


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

📘

Please refer to the following guide. [Create a ZEPETO Character]


  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.


  1. 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.


  1. Create a total of 2 teleportation points in the same way.
2736

Example of Teleport Point A


2736

Example of Teleport Point B


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


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.
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);
    }
}

  1. After you finish writing the script, add the script to the Portal object that will initiate the teleport.
  2. In the inspector, assign the Destination Object.
    • Destination Object : a portal object to arrive at the end of the teleport.
424

Example Script Setting Screen


STEP 3 : Run


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


❗️

Caution

  • 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.

📘

Multiplay Sample - Zepeto Multiplay Component

https://github.com/naverz/zepeto-multiplay-example/tree/main/Assets/Zepeto Multiplay Component