Behavior trees and controller input

I am trying to read controller inputs from behavior tree nodes.
I know this may be strange to you but I find it very usefull the use behaviour trees to organize player interface.

My main problem is that when I want to add the action event to my task’s blueprint the “Action Events” category is not available. I guess that makes sense since behavior trees do not have an input component.

Any idea?

Thanks,

Edit: In the pawn’s event graph it is possible to access such event but not in the task’s event graph.
Also I have tried to use custom events but they don’t allow me to target the task precisely. Also I would like to have many tasks listening to such events.

Try casting Owner Actor to whatever class you’re controlling with your BT and then extract InputComponent from it. I’m not familiar with input mechanics at all, so if taking a hold of InputComponent turns out to be impossible you can always just call functions on the actor your control with the BT.

Cheers,

–mieszko

Try casting Owner Actor to whatever class you’re controlling with your BT and then extract InputComponent from it.
You mean in the task’s c++ code I need to get the input component of the controlled actor and read inputs from there? By using BindInput for example?

Calling functions from the BT task on actors in the game is what I am doing already.

However I don’t seem to find any way of getting a hold on the input component from the task for the simple reason that there is no GetOwnerActor type function in UBTNode.

My problem is that I cannot catch controller events (input events) from a BT Node

First of all I need information on what are you using to implement your BT nodes, C++ or BP? But regardless, one thing to note about our BT implementation is that nodes as (generally speaking) “skeletons” and operate on given contest (expressed by BehaviorTreeComponent instance in case of C++ or Owner Actor in BP).

Would anyone know how to retrieve the AAIController from a UBTNode ? From there I could get the possessed pawn.

Like I said, UBTNodes are skeletons and as such don’t have information on any specific AI since a single BT node instance is being used by all AIs using the same BT asset. You get a “context” as BehaviorTreeComponent reference (or pointer, depending on the version you’re using) when functions are being called on given BT node instance for a specific AI (the owner of BehaviorTreeComponent instance).

Note: This question is not resolved yet… why was is marked as resolved ?

nodes as (generally speaking)
“skeletons” and operate on given
contest (expressed by
BehaviorTreeComponent instance in case
of C++ or Owner Actor in BP).

Thanks for pointing that out! So I wrote that bit of code:
AAIController *const aiController = OwnerComp->GetAIOwner();
APawn *const pawn = aiController->GetPawn();
UInputComponent *const inputComponent = static_cast< UInputComponent * >( pawn->GetComponentByClass ( UInputComponent::StaticClass() ) );

But inputComponent is null. I managed to trace it and it seems to be because the pawn is not possessed by a AAPlayerController.
It would seem I would have to write a specialised class inheriting from character which manually calls CreatePlayerInputComponent().

What do you think?

Like I said, I don’t know much about Input code, but the BT part has been solved. I suggest you created a new thread regarding the details of your input question.

Okay thanks!