GetWorld() pointer to incomplete class type is not allowed

Hey! Plz Help. i do Replay System. A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums
This part displays an error

int32 APC_ReplaySpectator::GetCurrentReplayTotalTimeInSeconds() const
{
	
	if (GetWorld())
	{
		if (GetWorld()->DemoNetDriver)
		{
			return GetWorld()->DemoNetDriver->DemoTotalTime;
		}
	}

	return 0.f;
}

ERROR: pointer to incomplete class type is not allowed if (GetWorld()->DemoNetDriver)

Following instructions connect the following libraries:
#include "TP_StrategyWithSteam.h" #include "Engine/DemoNetDriver.h" #include "PC_ReplaySpectator.h"

And TP_StrategyWithSteam.h not found…

Add

#include "Engine/World.h"

THANK YOU, SO MUCH! :smiley:

Thanks mate. ! I am going to be more active in forums so people are encouraged to post answers, so will I when I find something.
To add on to his answer, look into IWYU of UE4, from now on you have to add all the header files of classes you intend to use, this is to reduce compile time.

You are literally GOD.

Right now, in the documentation says that we need to use this #include "Runtime/Engine/Classes/GameFramework/Actor.h" if we are handling an AActor, if we are handling an UWorld we have to use #include "Runtime/Engine/Classes/Engine/World.h".

Guys this doesn’t work for me. it’s an instant crash

You’re likely missing an if-check and accessing a null pointer.

I dont remember how i fixed it but thanks for replying