CREATE YOUR WORLD
Players & Characters: Tips

Measuring your character's height

4min
in this guide, we will show you how to measure the height of a local player's zepeto character according to the body type step 1 write a script to get the height value of the character add a gameobject to the scene and add the characterheight example script below import { debug, humanbodybones, vector3, waitforendofframe } from 'unityengine'; import { localplayer, zepetoplayers, zepetoplayer, knowsockets } from 'zepeto character controller'; import { zepetoscriptbehaviour } from 'zepeto script'; export default class characterheight extends zepetoscriptbehaviour { start() { zepetoplayers instance onaddedlocalplayer addlistener(() => { let player localplayer = zepetoplayers instance localplayer; this startcoroutine(this cogetzepetoheight( player zepetoplayer)); }); } cogetzepetoheight(zepeto zepetoplayer) { // use waitforendofframe to accurately obtain the joint positions of the character yield new waitforendofframe(); // get the position of the head const headposition = zepeto character getsocket(knowsockets head upper) position; // get the position of the left foot const leftfootposition = zepeto character zepetoanimator getbonetransform(humanbodybones leftfoot) position; // get the position of the right foot const rightfootposition = zepeto character zepetoanimator getbonetransform(humanbodybones rightfoot) position; // calculate the midpoint between the two feet const charactercenter = vector3 lerp(leftfootposition, rightfootposition, 0 5); // calculate the distance between the head and the character center const characterheight = vector3 distance(headposition, charactercenter); console log(`character height from ground ${characterheight}`); } } script description cogetzepetoheight(zepeto zepetoplayer) use getsocket to get the character's head socket position value to obtain the position value of the bottom center of the character, use getbonetransform to obtain the position value of both feet of the character use vector3 lerp to get the character's bottom center position value obtain the character's height value using the character's head socket and the center bottom position value step 2 run when you run it by clicking the play button, you can see the character's height value in the console log 👍 tip the way to measure the height in the example is to measure the character's height using the height value of the headsocket if you would like to measure the top position by modeling the character's head, hat, and accessories, please refer to the following link 📘 skinnedmeshrenderer localbounds https //docs unity3d com/manual/class skinnedmeshrenderer html https //docs unity3d com/manual/class skinnedmeshrenderer html https //docs unity3d com/2020 3/documentation/scriptreference/skinnedmeshrenderer localbounds html https //docs unity3d com/2020 3/documentation/scriptreference/skinnedmeshrenderer localbounds html