Pointer to incomplete class type is not allowed

Upon finishing lecture 90 I noticed an error that appears in my code to do with the line.

TotalMass += Actor->FindComponentByClass()->GetMass();

Where actor is underlined with the error
E0393 pointer to incomplete class type is not allowed

I’ve gone over my code and compared to the code provided in the resources which still brings up this error.
So I’ve narrowed it to be possibly the UE version or VS versions? Tried including various Actor.h files etc and that doesn’t seem to solve it.

I’m using UE 4.17.1 and VS17 15.3.4

Any ideas what may be causing this error as right now even with further progress of videos the issue prevents testing of the game.

It’s interesting, Visual Studio complains about that with GetWorld(), though it still compiles. I have a few Visual Studio “errors” highlighted at the moment. At any rate, I wonder if your missing UPrimitiveComponent generic in the FindComponentByClass() method is what’s causing you grief:

TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();

Here’s what the entire loop looks like in my code:

for (const auto* Actor : OverlappingActors)
{
	TotalMass += Actor->FindComponentByClass<UPrimitiveComponent>()->GetMass();
	UE_LOG(LogTemp, Warning, TEXT("TEST"));
	//UE_LOG(LogTemp, Warning, TEXT("%s on pressure plate", *Actor->GetName()));
}

I’m in the middle of trying to figure out what about that second log statement causes my stuff to not compile. As a Java dev, C++ makes life difficult at times!

Have you tried

TEXT(*Actor->GetName()+" on pressure plate")

Thanks for the response. Yeah still fails to compile. Not sure what the deal is (I use Incredibuild and I sometimes wonder if that could cause problems). At any rate I’ve just commented it out and moved on. It would be nice to know the issue, but I don’t want to iterate at it for any length of time.

I have the fix for you my friend, i did some digging and found out its just another missing #include file issue again. It must be put in the .CPP file like so.

This is how the top of my .CPP file looks like now, i simply added #include “Components/PrimitiveComponent.h”. All the other includes you see there i either added before this issue or were put there by default.

7 Likes

In case you haven’t figured it out yet (Id be surprised but still). There is only a misplaced parenthesis in your statement:

UE_LOG(LogTemp, Warning, TEXT("%s on pressure plate", *Actor->GetName())); has to become:

UE_LOG(LogTemp, Warning, TEXT("%s on pressure plate"), *Actor->GetName());

Thanks, @SturmWolf Wolf this worked for me!

Thank you so much,I was stuck for 2 hours:grinning:

Thanks so much, this worked for me and i learned a valuable lesson in the process

Privacy & Terms