By applying the guide on attaching objects to ZEPETO characters, you can implement riding vehicles like cars, airplanes, pets, etc., as if the character is riding them.
Please refer to the following guide [Attaching Objects to ZEPETO Characters]
Setting Up the Animator

To change the pose of the ZEPETO character when riding a vehicle as described above, you need to modify the Animator and set it up under ZEPETOPlayers.
- Create an Animator Controller by going to Project > Create > Animator Controller and rename it to VehicleZepetoAnimator.

- In the Animator tab, create an Empty state by selecting Create State > Empty.

- Rename it appropriately in the Inspector and assign animation clips to Motion.

- To use your desired animation clip files, refer to the Custom Animation guide.
Please refer to the following guide [Apply custom animation]
- Drag and drop VehicleZepetoAnimator onto ZEPETOPlayers to set it up.

Tips
- If the camera height needs to change depending on the size of the vehicle, you can preset the Camera LookOffset value in ZEPETOPlayers.
Example Code
- Create a TypeScript by going to Project > Create > ZEPETO > TypeScript and rename it to RideVehicle.
- Write a sample script as shown below.
- Note that the Vehicle Transform values in this example should be adjusted to match the Vehicle Prefab when actually applying it.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { ZepetoCharacter, ZepetoPlayers } from 'ZEPETO.Character.Controller';
import { Transform, Animator, GameObject, HumanBodyBones, Object, Vector3, Quaternion } from 'UnityEngine';
export default class RideVehicle extends ZepetoScriptBehaviour {
public vehiclePrefab : GameObject;
public bodyBone: HumanBodyBones;
private _localCharacter: ZepetoCharacter;
private _vehicle : GameObject;
Start() {
ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
// Find the local player and set it to _localCharacter.
this._localCharacter = ZepetoPlayers.instance.LocalPlayer.zepetoPlayer.character;
// Get the _localCharacter's animator component.
const animator: Animator = this._localCharacter.ZepetoAnimator;
// Get the position of the bone to attach the object to.
const bone: Transform = animator.GetBoneTransform(this.bodyBone);
// Create the Vehicle prefab.
this._vehicle = Object.Instantiate(this.vehiclePrefab, bone) as GameObject;
// Set Vehicle Transform
this._vehicle.transform.localPosition = new Vector3(0.5, 0,0);
this._vehicle.transform.localRotation = Quaternion.Euler(0, 0,90);
});
}
}
- After completing script writing, add the script to the GameObject in the Scene.
- In the Inspector, assign the vehicle's prefab resources and the Body Bone to be attached.
- Click the Play button, and you'll see the ZEPETO character riding on the vehicle.

Tips
- You can create various vehicles by simply changing the Prefab of the vehicle and the animation clips of the character.
Example of Size Change When Consuming Items
Here is a fun application example: implementing content where the character's size changes when consuming items while riding a vehicle.
- In this example, we prepared two types of prefabs and set the Tag of items that increase in size when consumed as "Increase" and items that decrease in size as "Decrease."
- Add Colliders to each item and make sure to check IsTrigger.


- Create a TypeScript by going to Project > Create > ZEPETO > TypeScript and rename it to ChangeObjectSize.
- Write a sample script as shown below.
import { Collider, GameObject, Vector3 } from 'UnityEngine';
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
export default class ChangeObjectSize extends ZepetoScriptBehaviour {
public vehicle: GameObject;
Start() {
}
OnTriggerEnter(collider: Collider) {
if (collider.tag === "Increase") {
this.gameObject.transform.localScale += new Vector3(0.1, 0.1, 0.1);
GameObject.Destroy(collider.gameObject);
}
if (collider.tag === "Decrease") {
const decreaseAmount = new Vector3(0.1, 0.1, 0.1);
const newScale = this.gameObject.transform.localScale - decreaseAmount;
GameObject.Destroy(collider.gameObject);
// Exception Handling: Ensure that the scale does not become smaller than (1, 1, 1)
if (newScale.x >= 1 && newScale.y >= 1 && newScale.z >= 1) {
this.gameObject.transform.localScale = newScale;
}
}
}
}
- The key part of the code is modifying the localScale to change the size of the ZEPETO character when it touches each item.
- Feel free to adjust the numbers for size change
- but make sure to handle exceptions to prevent the scale from becoming smaller than (1,1,1).
- This script should be added to the ZEPETO character created at runtime.
Therefore, modify the RideVehicle script that attaches the vehicle as follows.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { ZepetoCharacter, ZepetoPlayers } from 'ZEPETO.Character.Controller';
import { Transform, Animator, GameObject, HumanBodyBones, Object, Vector3, Quaternion } from 'UnityEngine';
import ChangeObjectSize from './ChangeObjectSize';
export default class RideVehicle extends ZepetoScriptBehaviour {
public vehiclePrefab : GameObject;
public bodyBone: HumanBodyBones;
private _localCharacter: ZepetoCharacter;
private _vehicle : GameObject;
Start() {
ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
// Find the local player and set it to _localCharacter.
this._localCharacter = ZepetoPlayers.instance.LocalPlayer.zepetoPlayer.character;
// Get the _localCharacter's animator component.
const animator: Animator = this._localCharacter.ZepetoAnimator;
// Get the position of the bone to attach the object to.
const bone: Transform = animator.GetBoneTransform(this.bodyBone);
// Create the Vehicle prefab.
this._vehicle = Object.Instantiate(this.vehiclePrefab, bone) as GameObject;
// Set Vehicle Transform
this._vehicle.transform.localPosition = new Vector3(0.5, 0,0);
this._vehicle.transform.localRotation = Quaternion.Euler(0, 0,90);
// Add Script to CharacterController
const sizeScript = this._localCharacter.gameObject.AddComponent<ChangeObjectSize>();
// Add the vehicle to the script's inspector
sizeScript.vehicle = this._vehicle;
});
}
}
- Code to add the ChangeObjectSize script at runtime has been added.
- Click the Play button, and you'll see the character's size changing each time it consumes an item.
