4.18.3 issue with TSubclassOf code and Spawning

So when its just the TSubclassOf getting the AProjectile there isn’t a compiler error and everything runs fine, but when I go ahead and try to spawn with GetWorld()->SpawnActor I get 4 compile errors.

They are:
Severity Code Description File Line
Error - C2027 - use of undefined type ‘AProjectile’ - SubclassOf.h - 55
Error - C3861 - ‘StaticClass’: identifier not found - SubclassOf.h - 55
- Failed to produce item fireBreak.dll - ERROR -
Error - MSB3075 - Verify that you have sufficient rights…- Microsoft… - 44

When I comment out the SpawnActor code, it compiles fine. When I take it out of the //, it fails all over again. Is this a new thing with the 4.18.3 update? Or am I miss-using the SpawnActor?

Just to be clear, I never touched or plan to touch the SubclassOf.h or any of those other files until I have gained much more proficiency in unreal c++ coding.
I have the Projectile.h included.
And I have tried different spawn configurations besides the 2nd one suggested in the tutorial.

Hi Ian, did you create the Projectile_BP blueprint class? And include the Projectile.h header file in both Tank.cpp and Tank.h files?
I updated to from 4.18.1 to 4.18.3 and noticed it didn’t break my project, but then I removed those in my files and got the same error that you got, so maybe you need to create the Projectile_BP blueprint class, if so here is lecture content that shows how to do it: Setting Up Projectiles Section 4, Lecture 146 (at 8m:56s).

Hope this helps you get it working.

Hey Dave,

Thanks for getting back to me. I have a Projectile_BP blueprint created, and I have the Projectile.h in the Tank.h header. I figure that since Tank.cpp calls Tank.h that the header call for Projectile would be included. If you are saying that it is what you need to do to progress, I will give it a try.

Also, aren’t we doing the forward declaration in the Tank.cpp? I am on another computer and don’t have access to my project, I will reply to this later.

What I have done up to this point is that I reinstalled Visual Studio, as the last error I get, when googled, I found that the most common problem is older files from visual studio 15 or later are remaining on my machine and causing confliction. Then once everything was reinstalled I cleaned the source file for my project and tried to recompile. So far it complied and allowed me to launch the project, and I needed to add class inside of the TSubclassOf

Example:
UPROPERTY(blah)
TSubclassOf<class AProjectile>(yada yada…);

That was what I used in order to get it to work, but I am cherry-picking portions of the lesson to use in another project that is constructed differently.

Privacy & Terms