Guides
Log In

Top View Example

You can implement various camera perspectives by disabling the provided ZepetoCamera and using a custom camera.


STEP 1 : Camera view setting

Adjust the Transform of the custom camera to compose the view at the desired angle.

In this guide, the Main Camera is used as the custom camera.

For Top view, refer to the following settings.

2292

STEP 2 : Script creation

Implement the ZEPETO character creation code in the scene by default.

πŸ“˜

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

Disable the ZEPETO Camera and create a script that makes the custom camera follow the ZEPETO character.

Select Create > ZEPETO > Typescript, and rename it to TopViewController.

Add the script to the TopViewController object.

Write the code as follows to make the custom camera follow the character:

import { Camera, Transform, Vector3 } from 'UnityEngine';
import { SpawnInfo, ZepetoPlayers } from 'ZEPETO.Character.Controller'
import { ZepetoScriptBehaviour } from 'ZEPETO.Script'
  
export default class TopViewController extends ZepetoScriptBehaviour {
  
    public customCamera : Camera;
    private localPlayerTr : Transform;
  
    Start() {  
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
            this.localPlayerTr = ZepetoPlayers.instance.LocalPlayer.zepetoPlayer.character.transform;
            // Disable the ZEPETO camera
             ZepetoPlayers.instance.LocalPlayer.zepetoCamera.gameObject.SetActive(false);
        }); 
    }
  
    LateUpdate() {
        if(this.localPlayerTr != null) {
            this.customCamera.transform.position = new Vector3(this.localPlayerTr.position.x, this.customCamera.transform.position.y, this.localPlayerTr.position.z);
        }
    }
}

Connect the camera object to the Inspector.

357

Now, press the [β–ΆοΈŽ(play)] button in the center of the screen.

You can confirm that the original ZepetoCamera is disabled, and the custom camera is activated.

600