Trouble with Forward Declarations

Right, so TWeakObjectPtr has a default constructor, and a constructor which takes a pointer. Only the latter of those performs the UObject type check, and it will have needed to see the type declaration to be able to do that (a forward declaration will not suffice).

This sounds like an issue with the instantiation of your TWeakObjectPtr rather than your declaration of it.

With regard to your question about how the the forward declaration is happening, you can do a forward declaration inline, so the following does forward declare AMyNeededClass, but only for the scope of that variable declaration (as an aside, I don’t like the inline version of forward declarations since it can cause issues with namespaces, but since UE4 doesn’t really use namespaces, it’s not so much of an issue here).

TWeakObjectPtr<class AMyNeededClass> PawnInstigator;