# VRoid

vrm importer : <https://github.com/vrm-c/UniVRM>

v0.129.0으로는 플레이하면 오류 나길래 v128로 다운그레이드

<figure><img src="/files/0wjV5wBWnPssaXo4ay9d" alt=""><figcaption></figcaption></figure>

눈 깜빡임 : <https://gist.github.com/AISebas/cc799c262ff71cd7d1e92f0dd7e5e5fb>\
눈 따라가기 : VRMInstance > select UI > LookAt

### 믹사모 애니메이션 적용 방법

* unity package manager > Unity Registry > fbx exporter 설치
* 모델을 씬에 올린 뒤 export fbx (안되면 fbx exporter 재설치)
* 믹사모에 fbx 파일 올린 뒤에 애니메이션 다운 받기
* 믹사모 파일 가져온 뒤 Rig > Animation Type > Humanoid
* 가져온 파일에서 애니메이션 클립만 따로 복사
* 애니메이션 클립 루트 모션 관련 필요한대로 설정

<figure><img src="/files/mtK74yDFjGjMOFRtFtoE" alt=""><figcaption></figcaption></figure>

### Turn head to target

**1.**

Aim Axis : 대상을 바라볼 축.\
Up Axis : 위가 될 축.\
해당 본의 local axis를 잘 보고 설정하면 됨.

**2.**

```cs
        var data = mac.data;
        data.sourceObjects.Clear();
        mac.data = data;
```

이렇게 해도 sourceObject는 없어지지 않음.

```cs
        var data = mac.data;
        data.sourceObjects = new WeightedTransformArray();
        mac.data = data;
```

이렇게 해야 함.

**3.**

```cs
    void Start()
    {
        defaultTarget = mac.data.sourceObjects[0].transform;
        defaultLocalPos = defaultTarget.localPosition;
    }

    void OnTriggerEnter(Collider other)
    {
        defaultTarget.transform.position = other.transform.position;
        print("OnTriggerEnter");
    }
```

런타임에 굳이 Target 바꾸지 말고 Target의 Transform을 바꿔라

**4.**

```cs
    void Update()
    {
        if (lookingSomething)
        {
            target.transform.position = Vector3.MoveTowards(target.transform.position, newTargetPos, turnFaceSpeed * Time.deltaTime * 2);
        }
        else
        {
            target.transform.localPosition = Vector3.MoveTowards(target.transform.localPosition, defaultLocalPos, turnFaceSpeed * Time.deltaTime);
        }
    }
```

### **표정 제어**&#x20;

Fcl\_All 계열은 VRM10Instance에서 덮어씌워버린다. 그 이외 파라미터들은 애니메이터로 제어 가능하다.

1. UniVRM의 기능을 이용하지 않을 거라면 Update Type을 None으로 두고 Animator로만 제어한다.
2. UniVRM 무시하고 계속 덮어씌우기 애니메이션 클립에서 키프레임을 하나 더 생성해서 애니메이션이 계속 재생되게 만들면 UniVRM의 덮어씌우기가 무시된다.
3. UniVRM의 Expression API 사용하기

* import했던 VRM 모델로 간다
* VRM 탭 > Extract Meta And Expressions

```cs
using UnityEngine;
using UniVRM10;

public class ChangeExpression : MonoBehaviour
{
    Vrm10Instance vrm;
    public ExpressionKey smile;

    void Start()
    {
        vrm = GetComponent<Vrm10Instance>();
        smile = ExpressionKey.CreateFromPreset(ExpressionPreset.happy);
    }

    void Update()
    {
        vrm.Runtime.Expression.SetWeight(smile, 1);
    }
}
```

### **워크플로 비교**

| 항목               | VRM → FBX 변환 후 사용                             | UniVRM 그대로 사용                                                                 |
| ---------------- | --------------------------------------------- | ----------------------------------------------------------------------------- |
| 리깅/애니메이션         | Unity Humanoid 리깅 자동 감지 → Animator 사용. 문제 없음. | 동일. 다만 VRM 표정(BlendShape)·눈동자 시선 제어가 이미 세팅됨.                                  |
| 표정 · BlendShape  | 변환 시 클립 이름·순서가 흐트러질 수 있어 수동 재매핑 필요.           | `VRMBlendShapeProxy`가 웃음/슬픔/놀람 등 표준 슬롯을 유지. 바로 Playable API·Timeline에서 호출 가능. |
| 헤어/치마 물리         | Dynamic Bone·Unity Physics 등을 직접 붙여야 함.       | `VRMSpringBone`이 메타데이터 기반으로 즉시 동작.                                            |
| 메타데이터 (작가, 라이선스) | FBX에는 안 남음 → 별도 관리 필요.                        | `VRMMeta` 컴포넌트에 포함(저작자·라이선스·연령등급).                                            |
| 런타임 아바타 교체       | Addressables 혹은 애셋번들 직접 제작 필요.                | `VRMImporterContext.LoadAsync(byte[])` 하나로 외부 VRM 파일 로드 가능.                   |
| 빌드 크기·성능         | 컴포넌트 수가 적어 약간 가벼움.                            | 스크립트·컴포넌트 추가(≈ 20 \~ 50 KB, 무시 가능).                                           |
| 유지보수             | 표준 FBX 파이프라인 → 아티스트·툴 전환 쉬움.                  | UniVRM 업데이트(0.x → 1.x) 따라가야 함.                                                |
| VR/소셜 지원         | 직접 구현.                                        | VCI / VRM 1.0 규격과 호환.                                                         |

### **UniVRM가 해주는 일**

| 컴포넌트                                          | 역할                                                   |
| --------------------------------------------- | ---------------------------------------------------- |
| `VRMHumanoidDescription`                      | IK 입력(목·눈·손) → Humanoid Rig 매핑 자동화                   |
| `VRMBlendShapeProxy`                          | 52 종 표준 BlendShape 슬롯 + 커스텀 클립 제어 API 제공             |
| `VRMSpringBone`, `VRMSpringBoneColliderGroup` | 머리카락·치마 물리(간단 반‑객체 동역학)                              |
| `VRMLookAtHead`, `VRMLookAtBoneApplyer`       | 카메라·타깃을 향해 눈/목 회전                                    |
| `VRMFirstPerson`                              | VR / 1인칭 렌더링 시 머리 숨김, 눈 깊이 클립 오프셋                    |
| `VRMMeta`                                     | Title, Author, Contact, License(商用/改変/再配布) 등 json 추출 |

| VRM 0.x                | VRM 1.0                                |
| ---------------------- | -------------------------------------- |
| **VRMBlendShapeProxy** | **`Vrm10Instance.Runtime.Expression`** |
| VRMLookAt              | `Vrm10Instance.Runtime.LookAt`         |
| VRMSpringBone          | `Vrm10Instance.Runtime.SpringBone`     |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lazyartisan.gitbook.io/note/main-page/r-and-d/vroid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
