StateTreeAiComponent not executing

I am trying to use the new StateTree AI Component, but cannot get it to run.
I created a Tree and a Pawn with an State Tree AI-Component. But when I Play in Editor, the Tree does not execute. Neither do Task run nor is the OnStateTreeRunStatusChanged-Callback called.
I tried attaching the TreeComponent to a custom AI Controller, but that did not trigger anything either.

Where do I have to attach the StateTree AI Component and what are other requirements to get it to run?

Not sure what your use-case is here, but I’ve had similar problems.

Try adding a StateTree component to your actor / pawn (not StateTreeAI) and then make a StateTree for it by using StateTreeComponentShema (not StateTreeAIComponentShema). Worked for me.

1 Like

Hi @Squamto!

Can you elaborate on what you are doing or provide some screenshots?

The StateTreeAIComponent was designed to be used by AI Controllers and as such, the context requires the component be owned by the AI Controller. The AI Controller would then possess the Pawn to run the StateTree. I have been using this for a StateTree guide in 5.4 and can confirm it is working.

If you do not need the AI controller to always be valid for your use case, you can use the StateTreeComponent. You could also have a Global Task that gathers an AI Controller if one exists during its EnterState event.

-James

FYI, the only way I managed to get the StateTreeAIComponent to run (using 5.4.2) was to manually restart the logic on the controller’s BeginPlay (even though the component is set to start the logic automatically, the state tree debugger will not pick it up unless I do this manual restart)

2 Likes

Thank you so much Mougli!!! Been pulling my hair for the past 3 days trying to figure out why my tree wouldn’t do anything.

1 Like

UE 5.4.3 | Blueprint without C++

There may be some function calls that we don’t understand yet.

I used this tutorial(Your First 60 Minutes with StateTree) to test many times.

BP_ThirdPersonCharacter is of course no problem, but if it is Pawn and Character, there will be two problems:

  1. StateTree is not executed

  2. MoveTo Task execution error?

For the first problem

Take the DetourCrowdController in the tutorial as an example, the Details panel AI->StartAILogicOnPossess of the Controller needs to be checked. (Even if you use the StartLogic node in BeginPlay of DetourCrowdController)

Finally, thank James Keeling for the very detailed and easy-to-understand tutorial.

Thank you for this - I can’t believe you figured this out. I was also stuck on this issue until your solution.

Hope they fix it soon.

I just wanted to also say that if you are on 5.5 and are using StateTrees without a Pawn (just an AiController), then, if you spawn the AiController via code, the StateTree will not run. It really wants a Pawn. It worked fine in 5.4, but seems to have regressed in 5.5.

Or maybe this is WIA…

I’m having this same problem in 5.5

I created a simple State Tree for the State Tree AI Component, I’m having the Player’s Blueprint spawn the NPC in, and absolutely nothing happens. I have tried calling Start Logic, Restart Logic, I have even tried Adding the State Tree AI Component Manually OnPossess hoping that if I create it and add it during run-time that it will start working.

It does not fire at all what so ever.
I have breakpoints set on the root and I am checking to see if it’s running and if not I am calling Start Logic to try and force it too run. If it runs I have it print a message but the message never prints because it never fires.

Just to clarify, that AI Controller in the image is in fact running…everything is working but the State Tree…it’s like it’s just Completely ignoring it. This AI Controller is a Child Class, my other State Trees I made for my other NPC’s a while back are running just fine…this one for some reason refuses to run…

Lol…I feel a bit ridiculous…I figured out the problem, it wasn’t executing because I set the wrong AI Controller Class, apparently it can’t execute if ran on a Class that does not match the one that was assigned.

It would be a nice feature if it would actually prohibit you from assigning one that doesn’t match to the component on that AI Controller Class