AI Controller spawned by AutoPossessAi doesn't possess the character

Hello,

I’ve recently ran into an issue where my AI Controller doesn’t possess it’s pawn. The controller itself is spawned by using the AutoPossessAI set to Placed in World or Spawned. It does spawn correctly, but just for some reason doesn’t possess. The character doesn’t have a different controller. Both Pawn on Controller and Controller or Character are null. Any idea what might be going on?

A bit more context:
AI Controller is a C++ class:

UCLASS()
class GP2_API AGP2_AIController : public AAIController
{
  //stuff
}

Then I create a Blueprint class that takes this AGP2_AIController as parent and change nothing there:

The character has seemingly all set up correctly:

Characters are spawned by an unrelated otherwise class simply like this:

ACharacterBase* TempCharacter = GetWorld()->SpawnActor<ACharacterBase>(CurrentClass, SpawnLocation, FRotator());

Proof that Controller and Pawn are null respectively:

Hello! This might be helpful https://answers.unrealengine.com/questions/1004334/spawn-actor-and-aicontroller-problem.html

Hello. Thanks for the suggestion, but I don’t think that’s it. I’m checking if the pawn is possessed/controller is possessing way into the game, not at the very beginning. They just remain unpossessed, even after multiple seconds/minutes.

Slight update: I also tried disabling autopossess, spawning controller and possessing manually, but the effect is the same. Here’s code:

ACharacterBase* TempCharacter = GetWorld()->SpawnActor<ACharacterBase>(CurrentClass, SpawnLocation, FRotator());

		if (!TempCharacter)
		{
			UE_LOG(LogTemp, Error, TEXT("Character was not spawned!"));
			return;
		}		
		AGP2_AIController* TempController = GetWorld()->SpawnActor<AGP2_AIController>(AGP2_AIController::StaticClass(), SpawnLocation, FRotator());
		if (!TempController)
		{
			UE_LOG(LogTemp, Error, TEXT("AI Controller was not spawned!"));
			return;
		}
		TempController->Possess(TempCharacter);

Don’t see anything related in log.

Ok, mystery solved. Turned out to be a dumb mistake on my end. I’ve overriden OnPossess() on the AI Controller, but didn’t use Super::OnPossess(). Addint it solved the issue.

1 Like