AgentFollowを終わらせたい

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

AgentFollowを終わらせたい

Post by akp2 »

Unity初心者です&Arbor2使わさせていただいています。

敵キャラをUnityのNavMeshAgentで操作しています。 複数の巡回ポイントを巡回させるスクリプトで動作しています。
この敵キャラオブジェクトにArbor FSMのDistance Transitionでプレイヤーとの距離を測り、Near Stateの範囲に入った場合にAgent Followを起動し、プレイヤーを追いかけるという処理をしています。 Far Stateになったら、再度上記の巡回させるスクリプトの動作に戻りたいのですがどうしたらいいでしょうか。

1、Arborを抜ける?
または
2、Arborで巡回する自作のスクリプトを動作させる

どうすればいいでしょうか。
User avatar
caitsithware
管理人
Posts: 493
Joined: 2015/08/17 12:41

Re: AgentFollowを終わらせたい

Post by caitsithware »

複数の巡回ポイントを巡回させるスクリプト
このスクリプトはArborのStateBehaviourではなく通常のMonoBehaviourで作られているということでしょうか。
でしたら、そのスクリプトのenabledを切り替えるStateBehaviourを作成するか、巡回させるスクリプトそのものをStateBehaviourに置き換える必要があります。

巡回スクリプトをArborに対応する方法

1、Arborを抜ける?

厳密にはちょっと意味合いが異なりますが、こちらが「そのスクリプトのenabledを切り替えるStateBehaviourを作成する」になります。

StateBehaviourとはステートに割り当てられるスクリプトで、MonoBehaviourと同じように記述して独自実装ができます。

巡回スクリプトのenabledを切り替えるStateBehaviourスクリプトの具体的な内容は、
  • OnStateBegin()が呼び出されたら巡回スクリプトのenabledをtrueに。
  • OnStateEnd()が呼び出されたら巡回スクリプトのenabledをfalseに。
という感じです。

詳しくはStateBehaviourのカスタマイズをご覧ください。

2、Arborで巡回する自作のスクリプトを動作させる

こちらは「巡回させるスクリプトそのものをStateBehaviourに置き換える」です。
上記「1、Arborを抜ける?」への回答の通りStateBehaviourは独自に実装できますので、すでにある巡回スクリプトをほぼそのままStateBehaviourに対応できます。

巡回と追跡を切り替える

上記2点いずれかを実装できましたら、「巡回」ステートと「追跡」ステートを作成します。
  • 「巡回」ステートには、上記で作成した巡回スクリプトを動作させるStateBehaviourと距離で遷移するDistanceTransitionを追加します。
    DistanceTransitionのNear Stateは「追跡」ステートへドラッグ&ドロップして遷移を設定しておきます。
  • 「追跡」ステートでは、AgentFollowとDistanceTransitionを追加し、DistanceTransitionのFar Stateを「巡回」ステートへドラッグ&ドロップしてステートが戻るように設定します。
以上で一通り動くようになるかと思います。
akp2

Re: AgentFollowを終わらせたい

Post by akp2 »

ありがとうございます。
とても参考になりました。


Last bumped by Anonymous on 2018/02/23 05:43.
Post Reply