CREATE YOUR WORLD
Players & Characters: Advanced

Teleport Implementation

9min
implements a portal through which the zepeto character can teleport to two different points step 1 setting the teleport target point implement the zepeto character creation code in scene as a default 📘 please refer to the following guide \[ creating 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 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 3\) create a total of 2 teleportation points in the same way 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); } } 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 step 3 run teleport the zepeto character from point a to point b when it is near the portal 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 https //github com/naverz/zepeto multiplay example/tree/main/assets/zepeto%20multiplay%20component