Quik qustions about AI.

So i have been looking around but not found the exact answers i need.
When working with AI in UE i notice that AIController has a APlayerState::.

But I assume it only has one as long as it bWantsPlayerState is true.?
Now if a AI/ NPC e.g: Animal, Enemy, have a PlayerState it will count as a player (show up as a player in e.g: Server Player Count)?
And if it do not have one, it will not, correct?

Thanks for any clarification, tips or tricks on the subject.

Cheers!

There’s a few ways you can think of AI.

You’ve got the AI players, which are like artificial brains which are playing the game with or against players. They will use a player controller to interact with the world, so it’s best to think of an AI player controller and a player controller as being interchangeable. Everything the player can see and do, the AI player can see and do, and vice versa.

If you’re building a game which contains non-playable characters (NPCs), they’ll also have AI but their behaviors can be scripted out without creating an AI player controller. Example: A flock of birds will have a bunch of bird actors which use flocking behavior.

The hard part is deciding where to draw the line between an NPC and an AI Player Controller. If you have a Kobold in a dungeon, does it get an AIPC or does it use a scripted AI behavior?

As for how UE4 treats AI player controllers, it’s pretty straight forward: AI Controllers and player controllers inherit from the AController class, and the game world object contains a list of AControllers.

's a snippet of code I use to do stuff with human players and AI players:



for (auto It = World->GetPlayerControllerIterator(); It; ++It)
{
	AStrategyPlayerController* SPC = Cast<AStrategyPlayerController>(*It);

	if (SPC)
	{
		if (!SPC->ControlledFaction->HasCapitol())
		{
			bPlayersReady = false;
		}
	}
}

if (bPlayersReady)
{
	//let the AI pick capitols
	for (auto It = World->GetControllerIterator(); It; ++It)
	{
		AStrategyAIController* AIC = Cast<AStrategyAIController>(*It);
		if (AIC)
		{
			AIC->PickStartTown(GetAllTowns());
		}
	}
}


Great thanks in this case it was related to animal AI.
(AI that is not possesed by players or act as players).
Cheers!