Guides
Log In

Create a ZEPETO Character

STEP 1 : Adding the ZEPETO Players component

In the Hierarchy window, select ZEPETO → ZepetoPlayers tab.

321

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

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

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

757

STEP 2 : To Load Character

Once the CharacterController setting is complete, use the provided script to load a character.

Add a GameObject in the Scene and add the ZEPETOScript as shown below.

978

You can load ZEPETO characters with controllers directly to the Scene.

Enter the ZEPETO ID in [ZEPETO_ID] to load the character.

The character loaded in this way is called a local player, which refers to a ZEPETO character that can be directly controlled by the user on their own device.


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 CharacterController extends ZepetoScriptBehaviour {

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

❗️

Caution

  • If you use this code, you will only play with the avatar of a specific ZEPETO ID.
  • When releasing a world, you need to modify the code based on the ZEPETO ID of the user who accesses the world, rather than the ZEPETO ID entered in the 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 CharacterController 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(() => {           
            let _player : LocalPlayer = ZepetoPlayers.instance.LocalPlayer;       
        });   
    }
}

❗️

Caution

  • Please manage the local player creation code to exist only once in the client script.
  • If the same player is created multiple times, the CreatePlayerWithUserId() script may be called elsewhere as well.

STEP 3 : Run

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

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.

600

👍

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