# How do you give AI players a PlayerState?

**URL:** <https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995>\
**Category:** Blueprint\
**Tags:** unreal-engine, bots, UE4, Blueprint, question\
**Created:** [February 4, 2015, 9:06pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995 "2015-02-04T21:06:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4e0518b61](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4e0518b61](https://forums.unrealengine.com/u/anonymous_user_4e0518b61)\
**Post date:** [February 4, 2015, 9:06pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/1 "2015-02-04T21:06:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kinzua01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kinzua01](https://forums.unrealengine.com/u/kinzua01)\
**Post date:** [June 17, 2015, 6:55am UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/2 "2015-06-17T06:55:43Z")

</div>

I am also pretty keen on understanding the same. Any help on this would be great ?

---

<div class="post-metadata">

**Author:** ![wilberolive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wilberolive](https://forums.unrealengine.com/u/wilberolive)\
**Post date:** [November 11, 2015, 9:23am UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/3 "2015-11-11T09:23:21Z")

</div>

I too would be interested in knowing how to do this as well. Anyone done this before?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9bc97718](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9bc97718](https://forums.unrealengine.com/u/anonymous_user_9bc97718)\
**Post date:** [January 4, 2016, 12:12am UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/4 "2016-01-04T00:12:41Z")

</div>

I haven’t tried this myself yet (just about to try it now!), but [this post](https://answers.unrealengine.com/questions/62160/blueprint-do-aicontrollers-characters-have-players.html) 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.

---

<div class="post-metadata">

**Author:** ![CrimsonHawk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CrimsonHawk](https://forums.unrealengine.com/u/CrimsonHawk)\
**Post date:** [November 14, 2016, 11:34pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/5 "2016-11-14T23:34:38Z")

</div>

It’s still a request!

---

<div class="post-metadata">

**Author:** ![Holybreath](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Holybreath](https://forums.unrealengine.com/u/Holybreath)\
**Post date:** [November 16, 2016, 4:36pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/6 "2016-11-16T16:36:09Z")

</div>

why tho? all your bots are pawns that can have variables like scores etc. You should use a Servers PlayerState to handle all bot scores and stuff.

---

<div class="post-metadata">

**Author:** ![CrimsonHawk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CrimsonHawk](https://forums.unrealengine.com/u/CrimsonHawk)\
**Post date:** [November 16, 2016, 5:09pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/7 "2016-11-16T17:09:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![FinalZer0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FinalZer0](https://forums.unrealengine.com/u/FinalZer0)\
**Post date:** [January 23, 2018, 9:00am UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/8 "2018-01-23T09:00:56Z")

</div>

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:

```
#include "AMyAIController.h"

AMyAIController::AMyAIController(const FObjectInitializer& ObjectInitializer)
     :Super(ObjectInitializer)
 {
    bWantsPlayerState = true;
 }

```

In your MyAIController.h write:

```
#pragma once

#include "CoreMinimal.h"
#include "AIController.h"
#include "AMyAIController.generated.h"

/**
 * 
 */
UCLASS()
class PROJECTNAME_API AMyAIController: public AAIController
{
	GENERATED_BODY()
	
	
public:
	AMyAIController(const FObjectInitializer& ObjectInitializer);
	
};

```

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 didn’t come up with this solution, I just concatenated data to here.  
Credits to users @Sam_the_Anon9 , @anonymous_user_f5a50610, @paradoc, @Tim C

---

<div class="post-metadata">

**Author:** ![JohnnyDale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnnyDale](https://forums.unrealengine.com/u/JohnnyDale)\
**Post date:** [January 24, 2018, 12:39pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/9 "2018-01-24T12:39:19Z")

</div>

I’m using 4.17 and doing what Ollinator does here works: [Hot to make a Playerstate for AIController - Character & Animation - Unreal Engine Forums](https://answers.unrealengine.com/questions/402137/hot-to-make-a-playerstate-for-aicontroller.html)

---

<div class="post-metadata">

**Author:** ![lotodore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lotodore](https://forums.unrealengine.com/u/lotodore)\
**Post date:** [July 6, 2018, 10:19pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/10 "2018-07-06T22:19:11Z")

</div>

As of UE 4.20, this is finally exposed to Blueprint, so the C++ class is no longer necessary.

---

<div class="post-metadata">

**Author:** ![Groliver7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Groliver7](https://forums.unrealengine.com/u/Groliver7)\
**Post date:** [April 11, 2019, 7:20pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/11 "2019-04-11T19:20:30Z")

</div>

how to though thanks

---

<div class="post-metadata">

**Author:** ![lotodore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lotodore](https://forums.unrealengine.com/u/lotodore)\
**Post date:** [April 11, 2019, 7:46pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/12 "2019-04-11T19:46:10Z")

</div>

Create a BP subclass of aicontroller, change properties:

![273941-aicontroller-player-state.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/a/c2a5c04171f261f93744b83900ef8643504163b3.jpeg)

---

<div class="post-metadata">

**Author:** ![Groliver7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Groliver7](https://forums.unrealengine.com/u/Groliver7)\
**Post date:** [April 11, 2019, 8:11pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/13 "2019-04-11T20:11:35Z")

</div>

Thanks mate!

---

<div class="post-metadata">

**Author:** ![IRJayJay](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IRJayJay](https://forums.unrealengine.com/u/IRJayJay)\
**Post date:** [April 10, 2022, 5:59pm UTC](https://forums.unrealengine.com/t/how-do-you-give-ai-players-a-playerstate/305995/14 "2022-04-10T17:59:10Z")

</div>

I’m on 4.27, this doesn’t seem to exist anymore. Any idea where I can find this?

Edit: Finally found it, click on Class Defaults first. I thought it was in class settings.
