As described in the title I need to be able to read controller input events in my BT nodes.
I like to organise player input contexts in behaviour trees so that I may easily swap and arrange them if need be.
What would be the best way to do that ?
So far I have written the following code:
AAIController *const aiController = OwnerComp->GetAIOwner();
APawn *const pawn = aiController->GetPawn();
// A new component needs to be created for some reason
// It seems to be because it is not possessed by any PlayerController
static const FName InputComponentName(TEXT("PawnInputComponent0"));
ConstructObject< UInputComponent >( UInputComponent::StaticClass(), pawn, InputComponentName );
UInputComponent *const inputComponent = static_cast< UInputComponent * >( pawn->GetComponentByClass ( UInputComponent::StaticClass() ) );
if ( inputComponent )
{
inputComponent->BindAction( "ValidateAction", IE_Pressed, this, &UBTTaskNode_InputMove::OnValidateAction );
inputComponent->BindAction( "ToggleNextUnit", IE_Pressed, this, &UBTTaskNode_InputMove::ToggleNextUnit );
inputComponent->BindAction( "TogglePreviousUnit", IE_Pressed, this, &UBTTaskNode_InputMove::TogglePreviousUnit );
}
But that doesn’t work, my callbacks ( OnValidateAction, ToggleNextUnit, TogglePreviousUnit ) are not called.
Any ideas?
Thanks : )
PS: I originally posted this here Behavior trees and controller input - Programming & Scripting - Epic Developer Community Forums