あなたの世界を作りなさい
プレイヤーとキャラクター: 上級
テレポート実装
9min
ZEPETOキャラクターが2つの異なるポイントにテレポートできるポータルを実装します。

- シーンにZEPETOキャラクター作成コードをデフォルトとして実装します。
📘 以下のガイドを参照してください。[ZEPETOキャラクターを作成する]
1) テレポートするポイントを作成します。
- このガイドでは、これらをAポイントとBポイントと呼びます。
- 階層を作成 > 3Dオブジェクト > プレーンを作成し、Plane_Aに名前を変更します。

2) テレポートを開始するポータルオブジェクトを追加します。
- オブジェクトと相互作用するためにコライダーを追加してください。
- 衝突を検出するためのエリアのサイズを調整します。
- Is Triggerを確認してください。

3) 同様の方法で合計2つのテレポートポイントを作成します。

テレポートポイントAの例

テレポートポイントBの例
- ポイントが重ならないように位置を調整します。

1) プロジェクトを作成 > 作成 > ZEPETO > TypeScript として名前を Teleport に変更します。
2) 以下のようなサンプルスクリプトを書きます。
- スクリプトがアタッチされているオブジェクトのコライダーエリア内でZEPETOキャラクターとの衝突が検出されたときに、destinationObjectとともにテレポートするロジック。
3) スクリプトの記述が完了したら、テレポートを開始するポータルオブジェクトにスクリプトを追加します。
4) インスペクターで、Destination Object を割り当てます。
- Destination Object : テレポートの終点に到着するポータルオブジェクト。

ポータルの近くにいるときに、ZEPETOキャラクターをポイントAからポイントBにテレポートします。

- このガイドは、私が操作するローカルプレイヤーのテレポートのみを扱います。
- マルチプレイヤーの世界の場合、他のプレイヤーの位置の同期が追加で必要です。
- マルチプレイヤーサンプルの同期コンポーネントを使用すると、位置の同期が簡単に実装できます。
📘 マルチプレイサンプル - Zepetoマルチプレイコンポーネント https://github.com/naverz/zepeto-multiplay-example/tree/main/Assets/Zepeto Multiplay Component