CREATE YOUR WORLD
Players & Characters: Advanced
Changing the collision area of the ZEPETO character
4min
regardless of the zepeto character's body shape, the size of the character controller's collision area is consistent for all the collision area of the character controller is tailored to the basic body shape and is cylindrical in form in the runtime's scene mode, by selecting a generated zepeto character, you can view the character controller's collision area the height of a zepeto character can vary based on its body shape or the items equipped when there's a significant difference from the basic body shape, the collision area can sometimes appear unnatural 📘 please refer to the following guide \[ measuring your character's height docid 7 vc4r17jitalvlasymk9 ] in such instances, you can modify the collider attribute value of the character controller using scripts during runtime height the height of the collision area center the central axis of the collision area radius the radius of the collision area please note, the values used in the examples are set for the test world and test account adjust the settings to suit your world in the example, the radius value wasn't altered import {humanbodybones, vector3, waitforendofframe, waitforseconds } from 'unityengine'; import {knowsockets, localplayer, zepetoplayers, zepetoplayer } from 'zepeto character controller'; import { zepetoscriptbehaviour } from 'zepeto script'; export default class changecollider extends zepetoscriptbehaviour { private localplayer localplayer; start() { zepetoplayers instance onaddedlocalplayer addlistener(() => { this localplayer = zepetoplayers instance localplayer; // measure the height of the local character this startcoroutine(this cogetzepetoheight(this localplayer zepetoplayer)); }); } cogetzepetoheight(zepeto zepetoplayer) { yield new waitforendofframe(); const headposition = zepeto character getsocket(knowsockets head upper) position; const leftfootposition = zepeto character zepetoanimator getbonetransform(humanbodybones leftfoot) position; const rightfootposition = zepeto character zepetoanimator getbonetransform(humanbodybones rightfoot) position; const charactercenter = vector3 lerp(leftfootposition, rightfootposition, 0 5); const characterheight = vector3 distance(headposition, charactercenter); // height of the local character console log(characterheight); // setting the height and center point based on a ratio, assuming the height of the basic body shape to be about 0 85 let controllerheight = characterheight / 0 85 1 2; let controllercentery = controllerheight / 2; this localplayer zepetoplayer character charactercontroller height = controllerheight; this localplayer zepetoplayer character charactercontroller center = new vector3(0, controllercentery, 0); } } the essential script involves accessing the character controller and modifying the properties’ values this localplayer zepetoplayer character charactercontroller height = number; this localplayer zepetoplayer character charactercontroller center = vector3; there may be instances where you cannot measure the height correctly for avatars wearing specific unique items