I would like to add bot players to my game. Spawning an AIController and making it possess a pawn is not a problem, but how do you give it a PlayerState?
There is no way to set a controller’s player state, and if you spawn an AIController, it won’t get any. Without a player state, bots are practically useless - I want them to have scores, names etc. like normal players.
I would have expected that there was something like CreatePlayer just for bots, but it appears that there is no out-of-the-box handling for bots whatsoever. Or, at least, none of it is exposed to Blueprint (e.g. InitPlayerState is not).
How can I get proper bot players to work using Blueprint?
I haven’t tried this myself yet (just about to try it now!), but this post seems to have the answer to this. It looks as though you can’t do it from blueprints, but there is a c++ variable that can be set to give AI’s PlayerStates.
Because pawn are not supposed to store anything like scores. Pawns get destroyed, the controllers don’t. Player states made for containing these informations. And we would like to make AI players just by swapping out the controllers.
I managed to get PlayerState to AI successfully. First, you can’t get PlayerState for AI in Blueprint, you have to do it c++ way. Convert your project to c++ project if needed. Then create new c++ class with name “MyAIController” (name it what ever you like).