Download

Get A pointer to the AIController in Character Class

I am trying to create AI for my game. I would like to keep all logic in the pawn code and use the AIController simply for the nav mesh movement capability but I cant seem to set a AAIController variable on the character header or cast the controller to AAIController on the cpp, anyone know how I can do this?

#include “AIController.h”

// Called to bind functionality to input
void AEnemy::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);

AAIController* AI = Cast<AAIController>(GetController());

}

this on my cpp gives me this on the compiler:

Error C2440 ‘initializing’: cannot convert from ‘AController *’ to ‘AAIController *’

k so I broke down and create a class that extended the AIController and ended up spawning the controller and possessing the pawn on beginplay, just seams like a waist of code…