StateへのBehaviourの動的な追加・削除について

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を確認の上、それでも使い方がわからない場合にご質問ください。欲しい機能の記載がドキュメントにない場合は機能が元から存在しない可能性が高いので要望フォーラムへ。
nice

StateへのBehaviourの動的な追加・削除について

Post by nice »

お世話になります。
あるState内のBehaviourスクリプトから、他Stateへ動的にBehaviourを追加・削除する方法はありますでしょうか?

想定しているシチューションとしては、
アクションゲームで、使用中には移動できなくなる技がいくつかあり、
技を使用する際に「技使用中状態」へ遷移させたいのですが、
技の数だけStateを作るのではなく、
Stateは「移動できなくなる技実行中 状態」という1つにまとめ、
Behaviourだけを使用する技に応じて差し替えた上で遷移したい、と考えております。

また、何か他に良い方法がありましたら教えて頂けると助かります。
それでは、よろしくおねがいします。
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: StateへのBehaviourの動的な追加・削除について

Post by caitsithware »

Behaviourの動的な追加/削除は自作StateBehaviourを作成することでできます。

追加についてのメソッドは、StateのAddBehaviour
もしくは、StateBehaviourのAddBehaviourです。

削除については、StateBehaviourのDestroyとなっています。

また他の方法としましては、技用オブジェクトを別途作成し、メッセージを介して技が終了するまで待機する方法もあります。
その場合、TriggerTransitionで待機し、
技用オブジェクトでは、SendTriggerSendTriggerUpwardsなどで技が終了したことを通知する形になります。
nice

Re: StateへのBehaviourの動的な追加・削除について

Post by nice »

迅速なご回答、大変助かります。

教えて頂いたメソッドを使ってBehaviourの追加/削除を試してみたいと思います。
また、ご提案頂いたTriggerを使った方法についても検討してみたいと思います。

ありがとうございました。


Last bumped by Anonymous on 2017/01/05 17:29.
Post Reply