Pointer to incomplete class type is not allowed

I’ve been trying to make a simple game where the player hits a target and is then rewarded with points.

void ABullet::OnBulletHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult & Hit)
{
if (ATarget * Target = Cast(OtherActor))
{
if (ASomeGameMode * GM = Cast(GetWorld()->GetAuthGameMode()))
{
GM->OnTargetHit();
}
}

}

the error appears at the “GetWorld” section of the code
i have included all the necessary files for this to work, yet it doesn’t

assuming you have included all the necessary includes

#include "Engine/World.h"
#include "SomeGameMode.h"
#include "Target.h"
#include "GameFramework/Actor.h" (probably included from your Bullet.h file)
#include "GameFramework/GameModeBase.h" (probably included from your SomeGameMode.h file)

shouldn’t it be something like this?

void ABullet::OnBulletHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult & Hit) 
{ 
	if (auto* Target = Cast<ATarget>(OtherActor))
	{
		if (auto* GM = Cast<ASomeGameMode>(GetWorld()->GetAuthGameMode()))
		{
			GM->OnTargetHit();
		}
	}
}

This fixed it, thank you very much

Glad to help,
could you pls accept the answer I’m a little OCD about not closed questions :stuck_out_tongue: