I tried to spawn AI characters with “Spawn AI from Class” node. However playerstate is none when I try to access it in the character’s blueprint function. The playstate array from gamemode blueprint also only has one item, which is from the player.
AI is not a player, so AIController does not create PlayerState by default. But it got mechanisms for enableing PlayerState for AI but it seem its not accesable via blueprint.
Also Controller class have funtion to init state for controller
So you need to do it in C++, it actully sould be easy, just use “Add Code to Project” (you will need to make your project C++), create class based of AIController and name it AIPlayerController (or whater you like ; p) and in created cpp file you just add bWantsPlayerState = tru;e in constructor, like this
Thanks for the detailed explaination. I did take a look at the header file and it’s enabled there… I didn’t expect they disabled it in the constructor… haha…
for any other ue4 c++ newbs like myself, here’s a link to the updated syntax for this stuff as of 4.6 i believe: New Syntax. So in the case mentioned above where a player state is needed, ObjectInitializer is required instead, as well as a minor modification to the header file.