APawn::IsBotControlled
#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
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());
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?