I am running into an issue when trying to Forward Declare UProjectileMovementComponent with UE5. The Screenshots are what my code looks like and i am wondering why i am getting the error even though i have included GameFramework/ProjectileMovementComponent.h in my .cpp file? if i add class in front of UProjectileMovementComponent* ProjectileComp; in the .h file, i get a successful build. i am more curious and am looking to learn. thank you in advance
Just logically think it through. You have the include for the projectile movement component in the .cpp file, how on earth would the .h file know what UProjectileMovementComponent
is? Since you are not accessing any of its member variables / methods in your .h, you can simply forward declare it. Otherwise you would need to add the proper include to the .h file as well.
what @STRiFE.x is saying is put this above your UCLASS in your .h
class UProjectileMovementComponent;
if i add class in front of UProjectileMovementComponent* ProjectileComp; in the .h file, i get a successful build. i am more curious and am looking to learn
@Auran13 Think he already had that figured out. The wording of the question is rather confusing lol
ah yeah it got me, i thought he was saying he HAD forward declared when it wasn’t in his code show