Spawn bot with player state? - 4.17

I am trying to create a FPS game with bots (similar to shooter game example). I want the bots to behave just like other players, so I want them to have a player state to keep scores, names, team, etc.

I have not found a way to do this in blueprints. I stumbled upon a post showing how to do this in C++ (https://answers.unrealengine.com/questions/62160/blueprint-do-aicontrollers-characters-have-players.html), but it was for version 4.4 (I think). I know almost nothing about C++, so I do not know how to do it in version 4.17, which is what I am using.

Does anyone know what the updated code would look like? Thanks.

Figured this one out on my own. For anyone else with this question, here is what I did (again, this is Unreal Engine 4.17):

I created a C++ class. I named it BotAIController. It’s parent class is AIController.

In the .cpp file:

#include "BotAIController.h"


// Function that sets bWantsPlayerState.  bWantsPlayerState is a variable in the parent
void ABotAIController::SetWantsPlayerState(bool NewValue)
{
	bWantsPlayerState = NewValue;
}

In the .h file:

#pragma once

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

/**
 * 
 */
UCLASS()
class SPECVS_MK3_API ABotAIController : public AAIController
{
	GENERATED_BODY()
	
public:

// Sets the variable bWantsPlayerState
	UFUNCTION(BlueprintCallable, Category = "PlayerState")
	void SetWantsPlayerState(bool NewValue);

};

Remember, if you name your project or controller something different, you will have to make some minor changes to the code.

That’s it! It was much more simple than the code for 4.4, which, for anyone interested, looked something like this:

.cpp file:

#include "BotAIController.h"



ABotAIController::ABotAIController(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
	bWantsPlayerState = 1;
}

.h file:

#pragma once

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

/**
 * 
 */
UCLASS()
class SPECVS_MK3_API ABotAIController : public AAIController
{
	GENERATED_BODY()
	
public:

	ABotAIController(const FObjectInitializer& ObjectInitializer);

};

One thing I forgot to mention is that you also need to create a Blueprint. Right-click on your C++ class and click ‘create blueprint based on class’. Open the new blueprint, and in the construction script add the node ‘Set Wants Player State’ (the new function created in C++). Check the box called ‘NewValue’, and then it should work.

Cheers!