UGameplayStatics::SetPlayerControllerID
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Assigns a physical controller device ID to a local PlayerController, used when remapping which gamepad drives which player in split-screen games.
Caveats & Gotchas
- • Only works for local PlayerControllers — has no effect on remote players and does not log a warning when misused.
- • Assigning the same ControllerId to two different players causes input conflicts; both players will receive input from the same physical device with no engine-level prevention.
- • Calling this during Actor construction is flagged as unsafe and may produce undefined behaviour if the local player subsystem is not yet fully initialized.
Signature
static ENGINE_API void SetPlayerControllerID(APlayerController* Player, int32 ControllerId); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Player | APlayerController* | The local PlayerController to update. | — |
| ControllerId | int32 | The physical controller device ID to assign to this player. | — |
Return Type
void Example
Swap controllers between two local players C++
APlayerController* P1 = UGameplayStatics::GetPlayerController(this, 0);
APlayerController* P2 = UGameplayStatics::GetPlayerController(this, 1);
UGameplayStatics::SetPlayerControllerID(P1, 1);
UGameplayStatics::SetPlayerControllerID(P2, 0); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?