0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【UE5】BehaviorTree MoveToタスクにSelfActor以外のObjectKeyが指定できない!?

Posted at

MoveToタスクのBlackboardKeyパラメータ

MoveToタスクにはVectorもしくはActorが指定できるとのことだが、
Object型で追加したKeyのTargetActorが候補に出てこない。。

image.png

最初から用意されてるSelfActorはでてくるのにどうして、、

実装を見てみる

調べたところどうやら FBlackboardKeySelector でBlackboardKeyの型を制限しているみたい

BTTask_BlackboardBase.h
class UBTTask_BlackboardBase : public UBTTaskNode
{
	GENERATED_UCLASS_BODY()

	/** initialize any asset related data */
	AIMODULE_API virtual void InitializeFromAsset(UBehaviorTree& Asset) override;

	/** get name of selected blackboard key */
	AIMODULE_API FName GetSelectedBlackboardKey() const;

protected:

	/** blackboard key selector */
	UPROPERTY(EditAnywhere, Category=Blackboard)
	struct FBlackboardKeySelector BlackboardKey;
};

MoveToTaskの実装を見てみる

BTTask_MoveTo.cpp
UBTTask_MoveTo::UBTTask_MoveTo(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	NodeName = "Move To";
	INIT_TASK_NODE_NOTIFY_FLAGS();

	AcceptableRadius = GET_AI_CONFIG_VAR(AcceptanceRadius);
	bReachTestIncludesGoalRadius = bReachTestIncludesAgentRadius = bStopOnOverlap = GET_AI_CONFIG_VAR(bFinishMoveOnGoalOverlap);
	bAllowStrafe = GET_AI_CONFIG_VAR(bAllowStrafing);
	bAllowPartialPath = GET_AI_CONFIG_VAR(bAcceptPartialPaths);
	bTrackMovingGoal = true;
	bRequireNavigableEndLocation = true;
	bProjectGoalLocation = true;
	bUsePathfinding = true;

	bStopOnOverlapNeedsUpdate = true;

	ObservedBlackboardValueTolerance = AcceptableRadius * 0.95f;

	// accept only actors and vectors
	BlackboardKey.AddObjectFilter(this, GET_MEMBER_NAME_CHECKED(UBTTask_MoveTo, BlackboardKey), AActor::StaticClass());
	BlackboardKey.AddVectorFilter(this, GET_MEMBER_NAME_CHECKED(UBTTask_MoveTo, BlackboardKey));
}

なにやらObject型とVector型で制限していそう…!
……ん? Object型はさらにActorクラスで制限している!
これが原因っぽい

改めて自分の実装を確認する

image.png

追加したキーのKeyTypeを見てみるとObject以外にさらに設定できそうな項目が…!
Actorクラスを設定したところ、無事MoveTaskの候補にでてくるようになりました!

下記ドキュメントにはちゃんとActor型に設定している項目がありました。。
めんどくさがらずにドキュメントはちゃんと読もう😥

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?