GetWorld() pointer to incomplete class type not allowed

On lines 40-45 in my TankAIController.cpp it has this:

ATank* ATankAIController::GetPlayerTank() const
	auto PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
	if (!PlayerPawn) { return nullptr; }
	return Cast<ATank>(PlayerPawn);

Then, under GetWorld() it says error E0393, “pointer to incomplete class type not allowed”. Any help?

I just checked, and now line 68 in the TankPlayerController.cpp has the error under GetWorld().

Just a side note, it still compiles just fine.

Just another effect of IWYU – you’ll need to add

#include “Engine/World.h”

into your header to make IntelliSense recognize it


Pasting #include "Engine/World.h" into TankAIController.h does not fix it. On the contrary, it starts making

class BATTLETANK_API ATankAIController : public AAIController

the GENERATED_BODY() on line 16 in my TankAIController.h have an error as well.

That should go away when you switch over to “forward declarations” a little later in BattleTank; for now, at least IntelliSense will now be able to path through GetWorld()-> to suggest member functions. I share your frustration though. That GENERATED_BODY() red squiggly ought not to cause any actual compile errors though.

#include “Engine/World.h”

worked for me Thanks :metal:t3: :metal:t3:

1 Like

#include “Components/ActorComponent.h”
Because you may be using UWorld *UActorComponent::GetWorld()
and for intellisense it requires UActorComponent: header.

1 Like

I am getting the same error too, it compiles just fine but now I need to make the AI tank aim at my Tank so the GetPlayerTank dosent works properly , any suggestion how you fixed it

It’s been so long, I don’t remember. I don’t think I got that far in the course. Did you try including #include “Components/ActorComponent.h”? If that doesn’t work, you could try #include “Engine/World.h” or both.

#include “GameFramework/PlayerController.h”
Is also needed as your calling it…

The Code editor will show error on GetWorld but you have to include the stuff you are calling for the editor to know.


As you are calling it here…