Class 'UWorld' has not member 'GetFirstPlayerController'

UE4.22 / Visual Studio 2019 / Lecture 89 / OpenDoor-Script

ActorThatOpens = GetWorld()->GetFirtstPlayerController()->GetPawn(); // This seems to cause the error

I always get class ‘UWorld’ has not member ‘GetFirstPlayerController’ error in Visual Studio 2019. When I hover above GetFirtstPlayerController() the tooltip displays the same. So I checked for the class UWorld and cannot find the method there. Does this mean that it does not exist in Unreal 4.22 anymore or am I doing something wrong? How do I do this in UE 4.22 correctly to proceed with the lectures?

Did you include the header for UWorld?

Thanks for the quick answer. Actually I am not sure, if I have done the headers right. I tried to look up the API and think that it is “Engine/World.h” for UWorld. My headers in the OpenDoor.h are:

#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “Engine/TriggerVolume.h”
#include “Engine/World.h”
#include “GameFramework/Actor.h”
#include “GameFramework/Controller.h”
#include “OpenDoor.generated.h”

VS and UE4 are compiling successfully and the script works as intended. It seems that this is a problem with Visual Studio 2019. It is very irretating though. Every ‘GetWorld()’ has this wavy red line too.

Just noticed this

If that’s what you have in code then that’s a typo.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms