RealDocs

APlayerState::SetIsABot

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: ENGINE_API

Description

Sets the bot flag on the PlayerState and replicates it to clients. Normally called by the engine when an AIController possesses a pawn.

Caveats & Gotchas

  • Setting this to false on a PlayerState owned by an AIController will mislead clients into treating the bot as a human — only do this if you have a deliberate reason such as disguising an AI in a game mechanic.
  • Server-side only; changes made on a client are not replicated.

Signature

void SetIsABot(const bool bNewIsABot)

Parameters

Name Type Description Default
bNewIsABot const bool True to flag this PlayerState as belonging to a bot.

Return Type

void

Example

Mark a spawned bot's PlayerState on the server C++
// Typically the engine does this automatically, but manual example:
if (APlayerState* PS = BotController->GetPlayerState<APlayerState>())
{
    PS->SetIsABot(true);
    PS->SetPlayerName(TEXT("Bot_") + FString::FromInt(BotIndex));
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.