GameplayTask Resources

I’m trying to understand what does these functions do

template 
inline void AddRequiredResource()
{
	AddRequiredResource(T::StaticClass());
}

template 
inline void AddClaimedResource()
{
	AddClaimedResource(T::StaticClass());
}

Additionally, why does AITask has this function:

void UAITask::RequestAILogicLocking()
{
    AddClaimedResource();
}

This seems to set the controller to null? Finally, is this an attempt to have multiple requesting methods (to move a pawn in this case) that play nice with BehaviorTree?

Thanks,
Oscar

Hey Oscar,

AITasks (and by extension GameplayTasks) are indeed aimed to be (at some point) where all possible request sources meet to do the actual work. GameplayTasksComponent is responsible for managing tasks of different priorities and different requirements. Resources “required” by a task are the resources we need to have available to trigger the task (like “movement” needs to be available). Claimed resources, are the ones that will get “locked” when a task gets activated (so movement tasks can claim “movement” resource).

I’d love to hear your feedback on this approach. However, I suggest waiting for 4.12 before seriously using AITasks - there have been a lot of improvements done to the system due to one of our AI heavy projects (Fortnite) switching over to AI tasks. Paragon has just started using AI tasks as well.

Cheers,

–mieszko

What does claimed resources mean? I see that when I lock the AI the controller icon becomes a red devil icon. Looking up how the debug draw determine which icon to draw, it shows that the controller is null?

In general I like the idea of having a manager type object that juggles the priorities and limit executions per frame. The only concern I might have is the encouragement of using these nodes in just any Blueprint. This makes it hard to find all the behavior in one place (the behavior tree for example). I’m curious how well it is working when a project have many AITasks and at the same time still uses BehaviorTree.

I see! What’s the mechanism to prevent lower priority tasks never get executed? Yes I found that flag a while back and I have been using AITasks. They are good candidate to implement in code and then have users call them in BTTask both in C++ and Blueprint. I hope this is one of the “right” ways to use the AITasks right?

A claiming a resource means given AI’s GameplayTasksComponent takes a note of the fact and the resource is considered unavailable for lower priority tasks.

Locking “logic” resource doesn’t clear the controller. Look at AAIController::OnGameplayTaskResourcesClaimed for details.

We allow AITasks usage from BP to support AI scripting. You don’t have to do it, but if you want for example level-placed things to be able to tell AI how they’d be used AI tasks would be the way to go.

AITasks work with BTs flawlessly provided you have UE 4.12 and add following to your projects DefaultEngine.ini:

[/Script/AIModule.AISystem]
bEnableBTAITasks=True

What’s the mechanism to prevent lower priority tasks never get executed?

There’s none. If there’s always something higher priority using given resource, then a lower priority task needing that resource won’t get activated.

What’s the mechanism to prevent lower priority tasks never get executed?

Yes :slight_smile: