Description
Directly sets the Controller pointer on this pawn. This is a low-level assignment — prefer the full possession flow via AController::Possess() which calls PossessedBy() and other callbacks.
Caveats & Gotchas
- • Calling SetController() directly bypasses PossessedBy(), UnPossessed(), and the controller-changed delegates — use AController::Possess()/UnPossess() for the full possession lifecycle instead.
- • This function is used internally by the engine during replication (OnRep_Controller) to keep the pawn's Controller reference in sync on clients, where Possess() is not called.
Signature
ENGINE_API void SetController(AController* InController); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InController | AController* | The controller to assign to this pawn. Pass null to clear the controller reference. | — |
Return Type
void Example
Engine internal usage pattern (not for game code) C++
// Prefer the full possession flow in game code:
MyController->Possess(MyPawn);
// SetController is used by the engine internally, e.g. in replication:
// void APawn::OnRep_Controller() { /* calls SetController internally */ } Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?