AsyncTask value gets invalidated even though the task is still running

Hi,

I’m experimenting with state trees, and in one of my states I want to stop any movement my AI character might be performing. For that I am storing a reference to the async task AITaskMoveTo, obtained from “Move To Location or Actor” node, in a variable in my AI character.

I’m calling “Move To Location or Actor” node in two different places:

A GameplayBehavior

And a State Tree Task

Then in another state tree task, I’m trying to call “End Task” node to terminate any movement.

The issue I’m encountering is that the value set in the State Tree Task is valid when it reaches this point and the one that is set in the GameplayBehavior is invalid, even though the movement is still running.

Anyone know why this happens only for GameplayBehavior and what is the work around?

Kind regards

Can you check if it is moving because it is executing the other move to task that has a completely different reference?

You should probably move all your logic in a Behavior Tree and abort the sub branch via a decorator if need be.

1 Like

Thank you for your reply.

It’s moving as expected with both “MoveTo” nodes. The target locations for each are different.

To give a little bit more context, the GameplayBehavior belongs to a SmartObject and is being triggered by “UseSmartObject” node within a state tree task, then the GameplayBehavior calls the “MoveTo” node to the location specified in it.

So I know the Character is moving as intended. And it’s storing the async task value correctly, the thing is as soon as it reaches state tree task to end it, it is invalid for some reason, that I don’t understand.

Are you using the same controllers? Also, make sure that your controller class implements IGameplayTaskOwnerInterface.

1 Like

The AI Character has it’s own AIController, but it’s not using behavior tree it is using a state tree component instead.

On further inspection, the AsyncTask shows as valid on Character tick. So this is definitely related to the StateTreeTask and how it handles the Context Actor, which is where I’m storing the AsyncTask.