First of all, getting a pointer to a player controller in BP, is very easy. But it is troublesome in C++. I read other posts on how to do it. For instance, via GetWorld()->GetFirstPlayerController()
. When I called this via a UObject
derived object during execution of a custom event, GetWorld()
always returns null. If I used UGameplayStatics::GetPlayerController()
, it will require a valid pointer to UWorld
object. If I tried to execute GEngine->GetWorldFromContextObject()
, with its parameter set to “this” (the current object derived from UObject
), then it will also be invalid.
In short, is it impossible to get a pointer to APlayerController
(local player) or UWorld
from any UObject
-derived object, via any standard UE libraries, even though it is executed inside a custom event inside an AActor
-derived object?
Or is this a bug?