UE5/UE4 C++でプレイヤーコントローラ(APlayerController)を取得する(UGameplayStatics::GetPlayerController)
基礎的なものなのでほんとメモです。備忘録的な。
公式ドキュメントはこちら。
・UGameplayStatics::GetPlayerController
https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Kismet/UGameplayStatics/GetPlayerController/
以下の記述とインクルードで「APlayerController」を取得することができます。
基本的にはBPの「GetPlayerController」と同じですね。#include "Kismet/GameplayStatics.h"
// APlayerController の取得
APlayerController* aPlayerController = UGameplayStatics::GetPlayerController(this, 0);
C++では「UGameplayStatics::GetPlayerController」関数を使うようです。
ちなみに独自に「APlayerController」を継承したプレイヤーコントローラ(PlayerController)を取得する場合はこうなります。
こちらも「Cast」してあげるだけなので簡単なのかなと思います。#include "Kismet/GameplayStatics.h"
// APlayerController を継承した ANewPlayerController の取得
ANewPlayerController* aNewPlayerController = Cast< ANewPlayerController >(UGameplayStatics::GetPlayerController(this, 0));
| UE5 | 10:00 | comments:0 | trackbacks:0 | TOP↑