APawn
#include "GameFramework/Pawn.h"
Access: public
Specifiers: UCLASS
Description
APawn is the base class for all actors that can be possessed and controlled by a PlayerController or an AIController. Pawns receive input and can be moved through a MovementComponent.
Signature
class APawn : public AActor Caveats & Gotchas
- • Pawns require a Controller to receive input. Unpossessed pawns do not process player input.
- • For humanoid characters with walking/running/jumping, prefer ACharacter which extends APawn with a CharacterMovementComponent.
- • Possession can be replicated in multiplayer but the logic must be server-authoritative.
Example
Minimal pawn with input C++
void AMyPawn::SetupPlayerInputComponent(UInputComponent* InputComp)
{
Super::SetupPlayerInputComponent(InputComp);
InputComp->BindAxis("MoveForward", this, &AMyPawn::MoveForward);
}
void AMyPawn::MoveForward(float Value)
{
if (Value != 0.f && Controller)
{
AddMovementInput(GetActorForwardVector(), Value);
}
} Functions (2)
Utility 2 ▼
| Access | Type | Name |
|---|---|---|
| public | function | APawn::GetController |
| public | function | APawn::IsLocallyControlled |
See Also
Tags
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?