LoginSignup
2
2

More than 5 years have passed since last update.

プロ生ちゃん3Dモデルの表情を座標値で操作

Last updated at Posted at 2017-12-04

概要

プロ生ちゃん3Dモデル
http://3d.nicovideo.jp/works/td8608
の表情を以下の手法で操作します。
http://udasankoubou.blogspot.jp/2017/07/undebuggable-rittai-chan.html
※超絶簡易版として実装します。

bandicam-2017-12-05-00-24-56-519.gif
><がちょっと変ですけど組み合わせ吟味すれば少し良くなるハズ……

スクリプト

using UnityEngine;

public class ChangeFace : MonoBehaviour
{
    [SerializeField]
    SkinnedMeshRenderer skinn;

    [SerializeField]
    int up;

    [SerializeField]
    int down;

    [SerializeField]
    int left;

    [SerializeField]
    int right;

    void Update()
    {
        Vector2 stick = OVRInput.Get(OVRInput.RawAxis2D.RThumbstick) * 100;

        skinn.SetBlendShapeWeight(up, stick.y);
        if (stick.y < 0)
        {
            skinn.SetBlendShapeWeight(down, -stick.y);
        }

        skinn.SetBlendShapeWeight(right, stick.x);
        if (stick.x < 0)
        {
            skinn.SetBlendShapeWeight(left, -stick.x);
        }
    }
}

設定

プロ生ちゃんの表情設定はここにまとまってるみたいです。
ここで値を調整しながら上下左右に割り当てるindex(上から順に0から気合で数える。)を決めます。
「まばたき」と「笑い」のように一緒にすると変になる組み合わせは上下または左右に割り当てると操作時に自然です。
00.png

割り当てるindexが決まったら、SkinnにSkinnedMeshRendererが付いてるObjectを割り当て、上下左右にindexの値を設定します。
01.png

※今回のスクリプトは1つで上下左右4つなので、目と眉と口で3つ付けると表情がはっきりします。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2