AI does not AIM UP

Hi,

My AI keeps the focus towards the FP player, but does not aim up. The only thing that i’ve done differently is that i created the task in C++ instead of blueprints. Here is the code

EBTNodeResult::Type UFaceActor::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) {

UBlackboardComponent* blackBoard = OwnerComp.GetBlackboardComponent();
/*
FVector focus = blackBoard->GetValueAsVector(EnemyKey.SelectedKeyName);
if (focus.ContainsNaN()) {
	UE_LOG(LogClass, Warning, TEXT("Focus Failed"));
	return EBTNodeResult::Failed;
}
*/
AActor* focusActor = Cast<AActor>(blackBoard->GetValueAsObject(EnemyKey.SelectedKeyName));
if (!ensure(focusActor)) {
	UE_LOG(LogClass, Warning, TEXT("Focus Actor not found"));
}

//OwnerComp.GetAIOwner()->SetFocalPoint(focus);
OwnerComp.GetAIOwner()->SetFocus(focusActor);

return EBTNodeResult::Succeeded;

}

I’ve commented out the SetFocusPoint part, changed the key in the blackboard to an Object and everything works, except the AI does not AIM up.

UE Version: 4.15

Will appreciate any hints or tips…thanks

So after some debugging, and print nodes, i’ve managed to find:
the cast to UE4 node in the animation graph was failing.

At which point i realized that for the AI I had been using my custom C++ class based off the Character C++ class.

I’ve changed the cast to my enemy, copied over the crouch and jump events over from the UE4 character to the BP based off my custom character class and now all works!!!

Privacy & Terms