UGameplayStatics::GetPlayerControllerID
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the physical controller ID assigned to a local PlayerController. Returns -1 if no physical controller is assigned or if the player is not a local player.
Caveats & Gotchas
- • Only works for local PlayerControllers. Calling this on a remotely controlled player (server-side PC for a network client) always returns -1.
- • The controller ID is the physical device index, not the player index. On PC these are often the same, but on consoles a player may be signed in without an active physical controller.
Signature
static ENGINE_API int32 GetPlayerControllerID(APlayerController* Player); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Player | APlayerController* | The local PlayerController to query. | — |
Return Type
int32 Example
Check which physical controller a player is using C++
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
int32 DeviceId = UGameplayStatics::GetPlayerControllerID(PC);
UE_LOG(LogGame, Log, TEXT("Player 0 is using device %d"), DeviceId); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?