ACharacter::PossessedBy
#include "GameFramework/Character.h"
Access: public
Specifiers: virtualoverride
Description
Called on the server when a controller takes possession of this Character. ACharacter uses this to update the net owner and notify the CharacterMovementComponent of the new controller.
Caveats & Gotchas
- • Only called on the authority (server or standalone). Clients receive possession state through replication, not through this function — avoid placing client-side setup code here.
- • Always call Super::PossessedBy(NewController) first; the base APawn implementation sets the Controller reference and updates the net connection owner, which CharacterMovementComponent depends on.
Signature
ENGINE_API virtual void PossessedBy(AController* NewController) override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| NewController | AController* | The controller that is now possessing this Character. | — |
Return Type
void Example
Initialize server-side state when a player possesses the character C++
void AMyCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
// Server-only: grant default abilities now that we have a controller
if (AbilitySystemComponent)
{
AbilitySystemComponent->InitAbilityActorInfo(this, this);
}
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?