How do you give AI players a PlayerState?
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 am also pretty keen on understanding the same. Any help on this would be great ?
answered Jun 17 '15 at 06:55 AM
As of UE 4.20, this is finally exposed to Blueprint, so the C++ class is no longer necessary.
answered Jul 06 '18 at 10:19 PM
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).
In your MyAIController.cpp write:
In your MyAIController.h write:
And that kind of is it. You can now extend this class in your editor with a blueprint and default PlayerState is added to your AI Controller
I'm using 4.17 and doing what Ollinator does here works: https://answers.unrealengine.com/questions/402137/hot-to-make-a-playerstate-for-aicontroller.html
answered Jan 24 '18 at 12:39 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here