CREATE YOUR WORLD
Players & Characters: Basic

ZEPETO Character

17min

ZEPETOCharacter is basic ZEPETO character instance unit for loading in a World Scene.

To control the ZepetoCharacter, add the following import statement to the script.

TypeScript




ZepetoCharacter API

This API creates and removes ZEPETO character instances, including animator controller and character controller components.

API

Description

CreateByZepetoId(zepetoId: string, spawnInfo: SpawnInfo, complete: System.Action$1)

Use a ZEPETO ID to generate a ZEPETO character instance. Mainly used for NPC character creation.

CreateByUserId(userId: string, spawnInfo: SpawnInfo, complete: System.Action$1)

Create a ZEPETO character instance with UserId. Mainly used for NPC character creation.

RemoveCharacter(character: ZepetoCharacter)

Delete the character instance.



This API creates ZEPETO character model instances, excluding the Animator Controller and Character Controller components.

  • ZEPETO ID : This is the ID value that the user directly specifies and uses within the ZEPETO app.
  • User ID : This is a unique ID value that distinguishes users within the ZEPETO system, and is not a value exposed on the UI. You can check it using a script.



If you're interested in the ZepetoCharacter API, refer to the documentation:



Create/Delete Character

TypeScript




If you run the example, you can see that the CharacterModel on the left is created without the Animator Controller and Character Controller components as shown below.

Document image




Control Character

An interface where you can directly control the character will be provided through the script from a character instance in a Scene.

API

Description

MoveToPosition(position : Vector3)

Move the character to Position.

MoveContinuously(direction : Vector3)

Move continuously (update) in the direction the character is looking at.

MoveContinuously(direction : Vector2)

Move continuously (update) in the direction the character is looking at.

StopMoving()

Stop the character from moving.

Jump()

Character jumps to the Jump Power set.

DoubleJump()

Character double jumps with the currently set DoubleJump Power. (Applicable only when using MotionController V2)

Teleport(position: UnityEngine.Vector3, rotation: UnityEngine.Quaternion)

Character instantly moves to Transform.

SetGesture(gesture: UnityEngine.AnimationClip)

For the specified AnimationClip, the character motion is played. While SetGesture is running, the user's control inputs are not applied to the character. When AnimationClip's loop option is turned on, it continues to play until CancelGesture() is called.

CancelGesture()

Stop playback of the currently playing Animation Clip through SetGesture(). When CancelGesture() is executed, the user's control input is applied to the character control again.

Control Character example code.

TypeScript




If you run the example, you can see that the cloned character performs the specified actions in order as follows.

Document image


📘 Please refer to the following guide. [Creating an NPC]



Motion State

The API related to the Motion State of the ZEPETO character is as follows:

API

Description

motionState.useDoubleJump = (boolean);

Set whether the character can use DoubleJump.

motionState.doubleJumpPower = (number);

Set the character's DoubleJump power.

motionState.useLandingRoll = (boolean);

Set whether to use the character's LandingRoll.

motionState.landingRollSpeed = (number);

Set the character's LandingRoll speed value.

motionState.useMoveTurn = (boolean);

Set whether to use MoveTurn for the character.

motionState.Gravity = (number);

Set the character's gravity value.

motionState.CurrentJumpState

You can check the character's current jumping state. - None = -1, JumpIdle = 0, JumpMove = 1, JumpDash = 2, JumpDouble = 3

motionState.CurrentLandingState

You can check the character's current landing status. - None = -1, LandingSlight = 0, LandingDeep = 1, LandingRoll = 2

motionState.CurrentMoveState

You can check the current movement status of your character. - None = -1, MoveWalk = 0, MoveRun = 1

Motion State example code

TypeScript




Controlling ZEPETO Character Animator

API to control ZEPETO character animator

API

Description

StateMachine.constraintStateAnimation

Starting from version 1.6.0 of ZEPETO.World, transition of Animation played in CharacterStateMachine can be On/Off according to CharacterState of Motion V2. - true : Turn off ZepetoCharacter.CurrentState, which is affected by controller input, and control the desired animation clip.

👍 Example of using constraintStateAnimation

  • You want your character to use a swimming animation instead of a walking animation. You can apply a swimming animation clip to a new State and fix the State through constraintStateAnimation.
  • If you want to use gesture animation while moving a character, you can apply a gesture animation clip to a new State and move the character with the fixed State using constraintStateAnimation.
  • This can be used when you want to forcibly play a specific animation while temporarily ignoring the parameters values applied to the Animator State.



ZepetoAnimator

UnityEngine Animator functions are available in the form of ZepetoAnimator.

For example, if you want to set an Integer value for a specific Character Animator "State" parameter, you can use:

TypeScript


For more detailed usage, please refer to the UnityEngine Animator documentation and the sample script below.



Example code for controlling ZEPETO Character Animator

An example of animator control of a local player ZEPETO character controlled by the player.

TypeScript




If you run the example, you can see that when the value of StateMachine.constraintStateAnimation is True, the trasition of Animation played in CharacterStateMachine is Off.

If you set the StateMachine.constraintStateAnimation value to False, it will return to its original state.

Document image




Controlling CharacterShadow

Starting from version 1.11.3 of ZEPETO.CharacterController Package, an interface has been added to access the ZepetoCharacter Shadow object.

API Specifications:

CharacterShadow component interface


target

- Represents the object that serves as the reference for adjusting the transform of the CharacterShadow object. - By default, the ZEPETO character is set as the target. The transform of the CharacterShadow object is adjusted based on the bottom of the specified character.

autoSyncTransform

- A flag value that determines whether to adjust the position of the shadow. - The default value is true.

With this, you can control the shadow of the Zepeto character at runtime. Below is an example code that uses a toggle to turn the shadow on and off.

TypeScript




Document image