Caution
- You can only move between Worlds that has passed the review and has been activated.
- You will not enter the secret room of the target World.
ZepetoWorldContent must be imported to use the inter-World movement API.
import { ZepetoWorldContent } from 'ZEPETO.World';
The function definitions are as follows:
API | Description |
---|---|
public static MoveToWorld($worldId: string, $onError: System.Action$2<number, string>):void; | - After the World ID text is set as a parameter, the inter-World movement is executed when the function is called. - If it is a World that cannot be moved to, an error occurs and can be controlled through callback in case of an error. |
Below is a code sample that moves you to another world When you enter a specific GameObject trigger.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { ZepetoWorldContent } from 'ZEPETO.World';
import { Collider,Vector3,Quaternion } from 'UnityEngine';
import { ZepetoCharacter, ZepetoPlayer, ZepetoPlayers } from 'ZEPETO.Character.Controller';
export default class MoveToWorld extends ZepetoScriptBehaviour {
private zepetoCharacter: ZepetoCharacter;
// Ex: com.default.jumpworld
private worldId: string = "[World ID]";
Start() {
ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
this.zepetoCharacter = ZepetoPlayers.instance.LocalPlayer.zepetoPlayer.character;
});
}
OnTriggerEnter(collider: Collider) {
if ((this.zepetoCharacter == null) || (collider.gameObject != this.zepetoCharacter.gameObject)) {
return;
}
ZepetoWorldContent.MoveToWorld(this.worldId, (errCode, errMsg) => {
// Example of error callback processing
// (When implementing,try to implement it in various ways, such as pop-up windows)
console.log(`${errCode} - ${errMsg}`);
});
}
}