Studio GuideWorld SDK Guide
Log In

Creating a Zepeto character

STEP 0 : Adding a Base to the Scene

  • In the Hierarchy window, click on 3D Object → Plane.
  • Set the position of the Plane to X: 0, Y: 0, Z: 0, and set the size big enough to X: 10, Y: 1, Z: 10.

👍

Tips

  • The Plane is the most basic floor for testing purposes.
  • It does not matter what you use as long as it is an Object with a Collider.
  • As you become more familiar with World creation, you can make a cool map to replace the floor.
  • Without a platform, the character will fall as soon as it is created and will not be visible.

STEP 1 : Adding the ZEPETO Players component

In the Hierarchy window, select ZEPETO → ZepetoPlayers tab.


An object called ZepetoPlayers will be automatically created as shown below.

ZepetoPlayers is a component that manages character controller modules within the World.

757

Set values for character control and related functions can be set in the Inspector window.

  • You can usually set up things like the ZEPETO camera settings, character movement speed, jump height, etc.
  • In this example, we will use the default values.

📘

For detailed settings, please refer to the ZEPETO Character Controller guide. [ZEPETO Character Controller]


STEP 2 : To Load Character

To load a character, you need to create a new ZEPETOScript file.

  1. In the [Project] panel, select the [+] menu in the top left corner or select Assets → Create → ZEPETO → TypeScript.

  1. When the ZEPETOScript file is created, please enter the name as CharacterController. A script file will be created as shown below.

  1. In the Hierarchy → [+] menu → run the Create Empty menu.

  1. When creating an Empty GameObject, write CharacterController. A GameObject will be created as shown below.

  1. Drag the previously created CharacterController ZEPETOScript file onto the GameObject as a Component.

❗️

Caution

  • ZEPETOScript will not run unless it is added as a component to a GameObject in the Scene.

  1. First, enter your ZEPETO id to load the character into the Scene.
    Open the CharacterController ZEPETOScript file and run the script editor program.
    Then apply the example script below.
    • Please enter your ZEPETO ID where it says [ZEPETO_ID].
    • If your ZEPETO ID is 'abcd', you should enter it as ZepetoPlayers.instance.CreatePlayerWithZepetoId("", "abcd", new SpawnInfo(), true)

Script for loading a ZEPETO character with a specific ZEPETO ID

import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { SpawnInfo, ZepetoPlayers, LocalPlayer } from 'ZEPETO.Character.Controller';

export default class CharacterLoader extends ZepetoScriptBehaviour {

    Start() {
        ZepetoPlayers.instance.CreatePlayerWithZepetoId("", "[ZEPETO_ID]", new SpawnInfo(), true);
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
            const player: LocalPlayer = ZepetoPlayers.instance.LocalPlayer;
        });
    }
}

  1. After saving the script, please return to the Unity editor.
  • Please move on to the execution of STEP 3.

❗️

Caution

  • If you use this code, you will only play with the avatar of a specific ZEPETO ID.
  • When you launch your world, you will need to modify your code to be based on the ZEPETO ID of the user who accessed your world, instead of the ZEPETO ID you entered in your code. Please use the script below.

Script for loading the character of the logged-in ID

import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { SpawnInfo, ZepetoPlayers, LocalPlayer, ZepetoCharacter } from 'ZEPETO.Character.Controller';
import { WorldService } from 'ZEPETO.World'; 
 
export default class CharacterLoader extends ZepetoScriptBehaviour {   
 
    Start() {       
        // Grab the user id specified from logging into zepeto through the editor.
        ZepetoPlayers.instance.CreatePlayerWithUserId(WorldService.userId, new SpawnInfo(), true);            
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {           
            const player: LocalPlayer = ZepetoPlayers.instance.LocalPlayer;       
        });   
    }
}
  • This script creates a ZEPETO character based on the logged-in ID and does not accept a specific ZEPETO ID, so make sure to log into the Unity editor before testing.
  • After saving the script, please return to the Unity editor.
  • Please move on to the execution of STEP 3.

❗️

Caution

  • Please make sure that there is only one local player creation code in the client script.
  • If multiple identical players are created, the CreatePlayerWithUserId() script may be being called elsewhere.
  • A common mistake is to apply the multiplayer example code while leaving the character creation code in this guide intact, resulting in the character being created twice. Please manage this by commenting out one side.

STEP 3 : Run

Use the [▶︎(play)] button at the center of the screen to check that the CharacterController is working properly.

The loaded character is referred to as the local player's character, which means the ZEPETO character that users can control directly on their own devices.

CharacterController has a common character control Key Mapping for each Input Event corresponding to the device (PC/Mobile). Thus, the loaded character can be controlled in a Scene regardless of the platform.

On a PC, characters and cameras can be operated with a mouse. On a mobile device, characters and cameras can be operated with a virtual pad as shown in the screenshots below.

👍

The following input interfaces are supported for character control:

PC

  • Move: Keyboard arrows, WASD
  • Jump: Space
  • Double Jump : (Left) Shift
  • Zoom: Mouse wheel
  • Rotate: Screen drag

Mobile

  • Move: (Bottom left screen)virtual pad
  • Jump: (Bottom right screen)virtual pad button
  • Zoom: (Two fingers)screen drag
  • Rotate: (One finger)screen drag

If the ZEPETO character creation is not functioning properly, please go to Unity menu > Project Settings > Editor > Enter Play Mode Settings.

  • set the Enter Play Mode Options to Off.

STEP 4: Change the start position of the ZEPETO character

The start position of the ZEPETO character is created at UnityEngine.Vector3(0,0,0) unless otherwise set.

The rotation value is also generated at an angle of UnityEngine.Quaternion.Euler(0,0,0).

The character spawn position and rotation values are set using ZepetoPlayers.instance.CreatePlayerWithUserId(WorldService.userId, new SpawnInfo(), true); the function's argument, SpawnInfo(), will be generated.

So you can set the desired value for SpawnInfo() before calling the character creation function to make sure it spawns at a specific location.

We have pre-placed a 3D Object > Cube at location (0,0,0) on the map.

If you change the spawn location value for the character to the following, it will spawn on top of the Cube.

import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { SpawnInfo, ZepetoPlayers, LocalPlayer, ZepetoCharacter } from 'ZEPETO.Character.Controller';
import { WorldService } from 'ZEPETO.World';
import { Quaternion, Vector3 } from 'UnityEngine';

export default class CharacterController extends ZepetoScriptBehaviour {

    Start() {
        // Set Character Spawn Position
        const spawnInfo = new SpawnInfo();
        spawnInfo.position = new Vector3(0,2,0);
        // Set Character Spawn Rotation
        spawnInfo.rotation = Quaternion.Euler(0,0,0);

        // Grab the user id specified from logging into zepeto through the editor.
        ZepetoPlayers.instance.CreatePlayerWithUserId(WorldService.userId, spawnInfo, true);
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
            const player: LocalPlayer = ZepetoPlayers.instance.LocalPlayer;
        });
    }
}

Use the Play button in the center of the screen to check the creation of the character.


If you change the position and orientation values, you can also create a character lying down like this.

// Set Character Spawn Position
const spawnInfo = new SpawnInfo();
spawnInfo.position = new Vector3(2,1,2);
// Set Character Spawn Rotation
spawnInfo.rotation = Quaternion.Euler(90,0,0);