KITASENJU DESIGN BLOG

memo, html, javascript, unity

skinnedmeshとbone

手順

BoneWeight[] weightsを頂点数ぶん用意

weights[2].boneIndex0 = 1;//2番目の頂点のウェイトは1番目のボーンの影響下
weights[2].weight0 = 1;//その度合い

_mesh.boneWeights = weights;//ウェイトぶちこみ

ボーンを用意

ボーン作る。ボーンはgameObject(transform)。数は頂点数に限らない。 * mesh.bindposes * renderer.bones

        Transform[] bones = new Transform[2];//GameObjectつくったりする
        Matrix4x4[] bindPoses = new Matrix4x4[2];

        bindPoses[0] = bones[0].worldToLocalMatrix * transform.localToWorldMatrix;
        bindPoses[1] = bones[1].worldToLocalMatrix * transform.localToWorldMatrix;

        mesh.bindposes = bindPoses;//デフォルト位置的なやつだと思われる

        renderer.bones = bones;//動かすほう

参考

"FOOTER"