LoginSignup
5
6

More than 5 years have passed since last update.

Full Body Biped IKをAddComponentしたらeffectorsが空になる

Last updated at Posted at 2018-10-21

事の発端

Unityにおいて,動的に読み込んだVRMモデルをFinal IKのFull Body Biped IK(FBBIK)を使って手とか足の位置を制御したかった.
VRM読み込み時にFBBIKをAddComponent
そのFBBIKのleftHandEffectorとかのtargetを設定しようとしたら

IndexOutOfRangeException: Index was outside the bounds of the array.
RootMotion.FinalIK.IKSolverFullBodyBiped.GetEffector (RootMotion.FinalIK.FullBodyBipedEffector effector) (at Assets/Externals/Plugins/RootMotion/FinalIK/IK Solvers/IKSolverFullBodyBiped.cs:194)

と怒られた.
FBBIKのIKEffector[] effectorsが空のままになっているのが原因っぽい.
あらかじめインスペクタでFBBIKをアタッチしていると,この問題は発生しなかったのでAddComponentした場合はインスペクタからのアタッチ時には行われる何かが行われていないっぽい.

結論

AddComponentした後に以下の処理を追加する.

using RootMotion;


public FullBodyBipedIK fullBodyBipedIK;

fullBodyBipedIK = this.gameObject.AddComponent<FullBodyBipedIK>();

// ここから下の処理を追加

BipedReferences references = new BipedReferences();
BipedReferences.AutoDetectReferences(ref references, fullBodyBipedIK.transform, BipedReferences.AutoDetectParams.Default);
fullBodyBipedIK.SetReferences(references, null);

最初は肘曲げてないのが原因かな~とか思ってたけど違った.
あまり深く調査はしてないので参考までに.

参考

5
6
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
5
6