HumanBodyBones - Unity スクリプトリファレンス
Animator-GetBoneTransform - Unity スクリプトリファレンス
上記のスクリプトを使用すると、UnityのHumanoidBoneの各関節の参照となるTransformを取得出来るので、それを操作する。
Update()ではなく、LateUpdate()で行う必要がある
using System.Collections; using System.Collections.Generic; using UnityEngine; public class BoneMove : MonoBehaviour{ [SerializeField] Animator Anim; //操作したいHumanoidに付与してるAnimator [SerializeField] float x; [SerializeField] float y; [SerializeField] float z; Transform HandTF; void Start(){ HandTF = Anim.GetBoneTransform(HumanBodyBones.RightHand); } void LateUpdate(){ HandTF.rotation = Quaternion.Euler(x,y,z); } }
資料:右手のボーンをスクリプトで操作 pic.twitter.com/TPXxqwAtxD
— 光属性のアルモジナ(VRChat勢) (@arumogina) May 12, 2019
仕組みが良く分かってないのだが、モデル全体が回転すると手首も回転してしまう。
資料用:身体回転と同時に手首も回転する pic.twitter.com/NXfdH9zWUb
— 光属性のアルモジナ(VRChat勢) (@arumogina) May 12, 2019