RealDocs

APawn::IsBotControlled

function Engine Blueprint Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualUFUNCTIONBlueprintPure

Description

Returns true if this Pawn is controlled by an AI (possessed by an AIController rather than a PlayerController). Use this to branch logic between human players and bots.

Caveats & Gotchas

  • Returns false if the pawn is unpossessed — a pawn with no controller is considered neither bot nor player controlled. Check IsPawnControlled() first if you need to distinguish unpossessed pawns.
  • An AIController spawned via SpawnDefaultController will cause this to return true. If you override SpawnDefaultController to spawn a PlayerController, this will return false as expected.
  • This is not the same as checking bIsABot on APlayerState. A pawn with an AIController may lack a PlayerState entirely.

Signature

ENGINE_API virtual bool IsBotControlled() const;

Return Type

bool

Examples

Branch on BeginPlay to run player-only or bot-only setup logic Blueprint
Event BeginPlay Is Bot Controlled Target is Pawn Target Return Value Branch Condition Condition True False Print String In String Bot AI active Bot AI active Print String In String Player active Player active
Edit Blueprint graph Branch on BeginPlay to run player-only or bot-only setup logic
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Skip player-only logic for bots C++
void AMyPawn::OnHit(AActor* OtherActor)
{
	if (!IsBotControlled())
	{
		// Show screen-space damage indicator for human players only
		ShowDamageIndicator(OtherActor->GetActorLocation());
	}
}

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.