AgentControllerのAnimatorを動的に変更したい

Here is the forum to do the questions about how to use to Arbor developer.
Attention point:
  • We can not answer your questions about your project specific issues.
  • We can not answer your questions on Unity's specification issues.
  • Please check Arbor Documentation and ask a question if you still don't know how to use it. If the desired function is not described in the document, it is highly possible that the function does not exist from the beginning, so go to the request forum.

ここは、Arbor開発者へ使い方に関する質問を行うフォーラムです。
注意点:
  • ユーザー様のプロジェクトの仕様上の問題や設計に対する質問には答えられません。
  • Unityの仕様上の問題に対する質問には答えられません。
  • Arbor Documentationを確認の上、それでも使い方がわからない場合にご質問ください。欲しい機能の記載がドキュメントにない場合は機能が元から存在しない可能性が高いので要望フォーラムへ。

Forum rules
Here is the forum to do the questions about how to use to Arbor developer.
Attention point:
  • We can not answer your questions about your project specific issues.
  • We can not answer your questions on Unity's specification issues.
  • Please check Arbor Documentation and ask a question if you still don't know how to use it. If the desired function is not described in the document, it is highly possible that the function does not exist from the beginning, so go to the request forum.

ここは、Arbor開発者へ使い方に関する質問を行うフォーラムです。
注意点:
  • ユーザー様のプロジェクトの仕様上の問題や設計に対する質問には答えられません。
  • Unityの仕様上の問題に対する質問には答えられません。
  • Arbor Documentationを確認の上、それでも使い方がわからない場合にご質問ください。欲しい機能の記載がドキュメントにない場合は機能が元から存在しない可能性が高いので要望フォーラムへ。
k_nagamine

AgentControllerのAnimatorを動的に変更したい

Post by k_nagamine »

AgentControllerに設定するAnimatorの扱いについて質問させていただきます。

●状況
・ゲームオブジェクトAにBehaiourTreeとAgentControllerを付けて制御している
・NavMeshAgentはゲームオブジェクトAについている
・AnimatorはゲームオブジェクトAの子であるゲームオブジェクトBについている(Bは3Dモデル)

●オブジェクト構成
ゲームオブジェクトA(ルートオブジェクト、BehaiourTree、AgentController、NavMeshAgent付き)
 − ゲームオブジェクトB(3Dモデルオブジェクト、Animator付き)

●やりたいこと
ゲームオブジェクトBをキャラに応じて動的に生成したい。

●問題
動的に生成したゲームオブジェクトBのAnimatorをAgentControllerにセットする手段がない。
AgentControllerの_Animator変数はprivateで、Set関数やプロパティも用意されていないためセットできません。

●質問
AgentControllerにSetAnimator関数を追加して動的にセットできるようにしようと思いますが問題ないでしょうか?
また、AgentControllerの_Animatorが動的にセットできないようになっているのは何か意図がありますか?
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: AgentControllerのAnimatorを動的に変更したい

Post by caitsithware »

ご質問ありがとうございます。
k_nagamine wrote: 2018/07/12 06:39 AgentControllerにSetAnimator関数を追加して動的にセットできるようにしようと思いますが問題ないでしょうか?
また、AgentControllerの_Animatorが動的にセットできないようになっているのは何か意図がありますか?
まず意図についてですが、設定したAnimatorからパラメータ名を取得するようにInspector拡張をしている関係で、
Animatorを動的に変更した場合、パラメータを変更する際に指定した名前のパラメータがないというパターンを防ぎたいという感じでした。
Animator変更による動作は、それを行った人の自己責任でも問題なさそうなので、動的にもセットできるようにしようと思います。

次に、スクリプトを書き替える場合の問題点ですが、
次の更新で正式対応する際に、対応方法の違いにより正式版を適用するとコンパイルエラーが発生する可能性があります。
暫定的に変更すること自体は問題ありませんが、書き換える際は自己責任でお願いいたします。
k_nagamine

Re: AgentControllerのAnimatorを動的に変更したい

Post by k_nagamine »

ご回答ありがとうございます。
Animatorを動的に変更した場合、パラメータを変更する際に指定した名前のパラメータがないというパターンを防ぎたいという感じでした。
確かにそのパターンは発生しそうですね。
今回の場合はOverrideControllerを利用しておりパラメータは同一なので特に問題はなさそうです。
暫定的に変更すること自体は問題ありませんが、書き換える際は自己責任でお願いいたします。
はい、衝突した場合は正式版の方を使うようにまた対応します。

正式にご対応いただけるとのことでありがとうございます。
更新を楽しみにしてます!
Post Reply