CREATE YOUR WORLD
Players & Characters : Tips
캐릭터의 키 측정하기
3min
이 가이드에서는 로컬 플레이어의 zepeto 캐릭터의 신장을 몸 유형에 따라 측정하는 방법을 보여줍니다 1단계 캐릭터의 신장 값을 가져오는 스크립트 작성하기 씬에 gameobject를 추가하고 아래의 characterheight 예제 스크립트를 추가하세요 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}`); } } 스크립트 설명 cogetzepetoheight(zepeto zepetoplayer) 사용 getsocket 캐릭터의 머리 소켓 위치 값을 얻기 위해 캐릭터의 하단 중앙 위치 값을 얻으려면 getbonetransform 캐릭터의 두 발 위치 값을 얻기 위해 사용하세요 사용 vector3 lerp 캐릭터의 하단 중앙 위치 값을 얻기 위해 캐릭터의 머리 소켓과 중앙 하단 위치 값을 사용하여 캐릭터의 높이 값을 얻으세요 단계 2 실행 재생 버튼을 클릭하여 실행하면 콘솔 로그에서 캐릭터의 높이 값을 볼 수 있습니다 👍 팁 예제에서 높이를 측정하는 방법은 headsocket의 높이 값을 사용하여 캐릭터의 높이를 측정하는 것입니다 캐릭터의 머리, 모자 및 액세서리를 모델링하여 상단 위치를 측정하려면 다음 링크를 참조하십시오 📘 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